jQuery实现信息提示框(带有圆角框与动画)效果_jquery
本文实例讲述了jQuery实现信息提示框效果。分享给大家供大家参考。具体如下:
一个jquery提示框特效,黑色风可,且提示框是圆角形状,点击页面中间的几个文字,提示框信息就会动态显示,CSS和JS部分代码比较多。
先来看看运行效果如下:
具体代码如下:
<!DOCTYPE html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>jQuery实现的非常人性化的提示信息框效果</title> <script type="text/javascript" src="jquery-1.6.2.min.js"></script> <script type="text/javascript"> var humanMsg = { setup: function(appendTo, logName, msgOpacity) { humanMsg.msgID = 'humanMsg'; humanMsg.logID = 'humanMsgLog'; if (appendTo == undefined) appendTo = 'body'; if (logName == undefined) logName = 'Message Log'; humanMsg.msgOpacity = .8; if (msgOpacity != undefined) humanMsg.msgOpacity = parseFloat(msgOpacity); jQuery(appendTo).append('<div id="'+humanMsg.msgID+'" class="humanMsg"><div class="round"></div><p></p><div class="round"></div></div> <div id="'+humanMsg.logID+'"><p>'+logName+'</p><ul></ul></div>') jQuery('#'+humanMsg.logID+' p').click( function() { jQuery(this).siblings('ul').slideToggle() } ) }, displayMsg: function(msg) { if (msg == '') return; clearTimeout(humanMsg.t2); jQuery('#'+humanMsg.msgID+' p').html(msg) jQuery('#'+humanMsg.msgID+'').show().animate({ opacity: humanMsg.msgOpacity}, 200, function() { jQuery('#'+humanMsg.logID) .show().children('ul').prepend('<li>'+msg+'</li>') .children('li:first').slideDown(200) if ( jQuery('#'+humanMsg.logID+' ul').css('display') == 'none') { jQuery('#'+humanMsg.logID+' p').animate({ bottom: 40 }, 200, 'linear', function() { jQuery(this).animate({ bottom: 0 }, 300, 'easeOutBounce', function() { jQuery(this).css({ bottom: 0 }) }) }) } }) humanMsg.t1 = setTimeout("humanMsg.bindEvents()", 700) humanMsg.t2 = setTimeout("humanMsg.removeMsg()", 5000) }, bindEvents: function() { jQuery(window) .mousemove(humanMsg.removeMsg) .click(humanMsg.removeMsg) .keypress(humanMsg.removeMsg) }, removeMsg: function() { // Unbind mouse & keyboard jQuery(window) .unbind('mousemove', humanMsg.removeMsg) .unbind('click', humanMsg.removeMsg) .unbind('keypress', humanMsg.removeMsg) if (jQuery('#'+humanMsg.msgID).css('opacity') == humanMsg.msgOpacity) jQuery('#'+humanMsg.msgID).animate({ opacity: 0 }, 500, function() { jQuery(this).hide() }) } }; jQuery(document).ready(function(){ humanMsg.setup(); }) </script> <style> html, body { height: 100%; /* Damn you IE! */ } .humanMsg { font: normal 20px/50px Helvetica, Arial, Sans-Serif; letter-spacing: -1px; position: fixed; top: 130px; left: 25%; width: 50%; color: white; background-color: black; text-align: center; display: none; opacity: 0; z-index: 100000; } .humanMsg .round { border-left: solid 2px white; border-right: solid 2px white; font-size: 1px; height: 2px; } .humanMsg p { padding: .3em; display: inline; } .humanMsg a { display: none; } #humanMsgLog { font: normal 10px Helvetica, Arial, Sans-Serif; color: white; position: fixed; bottom: 0; left: 0; width: 100%; max-height: 200px; display: none; z-index: 10000; } #humanMsgLog p { position: relative; left: 50%; width: 200px; margin: 0; margin-left: -100px; padding: 0 10px; line-height: 20px; background: #333; text-align: center; white-space: pre; cursor: pointer; } #humanMsgLog p:hover { background: #222; } #humanMsgLog ul { margin: 0; padding: 0; position: relative; max-height: 180px; overflow: auto; display: none; } #humanMsgLog ul li { color: #555; font-size: 12px; list-style-type: none; border-bottom: 1px solid #ddd; line-height: 40px; display: none; padding: 0 20px; position: relative; overflow: hidden; white-space: pre; } #humanMsgLog ul li:hover { background: #f2f2f2; } #humanMsgLog ul li:first-child { margin-top: 1px; } #humanMsgLog ul li .error { color: orangered; } #humanMsgLog ul li .indent { position: absolute; top: 0; left: 100px; margin-right: 200px; height: inherit; } </style> <script> jQuery(document).ready(function() { jQuery('a.showmessage').click(function() { humanMsg.displayMsg('<strong>Success:</strong> <span class="indent">You clicked \''+jQuery(this).text()+'\'</span>'); return false; }) jQuery('a.showmessage:last').click(function() { humanMsg.displayMsg('"Your <strong>Earth</strong> will be reduced to a burned-out cinder."'); return false; }) }) </script> <style> p.links { position: absolute; font: 2em Helvetica, Arial, Sans-Serif; top: 40%; left: 50%; width: 400px; margin-left: -200px; text-align: center; } p.links a { text-decoration: none; color: #888; } p.links a:hover { color: #222; } p.links a.home { font-size: 10px; line-height: 30px; } </style> </head> <body> <p class="links"> <a href="#" class="showmessage">Klaatu</a> <a href="#" class="showmessage">Barada</a> <a href="#" class="showmessage">Nikto</a><br /> <a href="http://www.jb51.net/" class="home">Humanized Messages</a> </p> </body> </html>
希望本文所述对大家的jquery程序设计有所帮助。

热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

Video Face Swap
使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热门文章

热工具

记事本++7.3.1
好用且免费的代码编辑器

SublimeText3汉化版
中文版,非常好用

禅工作室 13.0.1
功能强大的PHP集成开发环境

Dreamweaver CS6
视觉化网页开发工具

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)

热门话题

jQuery引用方法详解:快速上手指南jQuery是一个流行的JavaScript库,被广泛用于网站开发中,它简化了JavaScript编程,并为开发者提供了丰富的功能和特性。本文将详细介绍jQuery的引用方法,并提供具体的代码示例,帮助读者快速上手。引入jQuery首先,我们需要在HTML文件中引入jQuery库。可以通过CDN链接的方式引入,也可以下载

jQuery中如何使用PUT请求方式?在jQuery中,发送PUT请求的方法与发送其他类型的请求类似,但需要注意一些细节和参数设置。PUT请求通常用于更新资源,例如更新数据库中的数据或更新服务器上的文件。以下是在jQuery中使用PUT请求方式的具体代码示例。首先,确保引入了jQuery库文件,然后可以通过以下方式发送PUT请求:$.ajax({u

jQuery如何移除元素的height属性?在前端开发中,经常会遇到需要操作元素的高度属性的需求。有时候,我们可能需要动态改变元素的高度,而有时候又需要移除元素的高度属性。本文将介绍如何使用jQuery来移除元素的高度属性,并提供具体的代码示例。在使用jQuery操作高度属性之前,我们首先需要了解CSS中的height属性。height属性用于设置元素的高度

标题:jQuery小技巧:快速修改页面所有a标签的文本在网页开发中,我们经常需要对页面中的元素进行修改和操作。在使用jQuery时,有时候需要一次性修改页面中所有a标签的文本内容,这样可以节省时间和精力。下面将介绍如何使用jQuery快速修改页面所有a标签的文本,同时给出具体的代码示例。首先,我们需要引入jQuery库文件,确保在页面中引入了以下代码:<

标题:使用jQuery修改所有a标签的文本内容jQuery是一款流行的JavaScript库,被广泛用于处理DOM操作。在网页开发中,经常会遇到需要修改页面上链接标签(a标签)的文本内容的需求。本文将介绍如何使用jQuery来实现这个目标,并提供具体的代码示例。首先,我们需要在页面中引入jQuery库。在HTML文件中添加以下代码:

jQuery是一种流行的JavaScript库,被广泛用于处理网页中的DOM操作和事件处理。在jQuery中,eq()方法是用来选择指定索引位置的元素的方法,具体使用方法和应用场景如下。在jQuery中,eq()方法选择指定索引位置的元素。索引位置从0开始计数,即第一个元素的索引是0,第二个元素的索引是1,依此类推。eq()方法的语法如下:$("s

如何判断jQuery元素是否具有特定属性?在使用jQuery操作DOM元素时,经常会遇到需要判断元素是否具有某个特定属性的情况。这种情况下,我们可以借助jQuery提供的方法来轻松实现这一功能。下面将介绍两种常用的方法来判断一个jQuery元素是否具有特定属性,并附上具体的代码示例。方法一:使用attr()方法和typeof操作符//判断元素是否具有特定属

jQuery是一个流行的JavaScript库,广泛用于网页开发中。在网页开发过程中,经常需要通过JavaScript动态地向表格中添加新行。本文将介绍如何使用jQuery为表格添加新行,并提供具体的代码示例。首先,我们需要在HTML页面中引入jQuery库。可以通过以下代码在标签中引入jQuery库:
