本文实例讲述了jQuery实现信息提示框效果。分享给大家供大家参考。具体如下:
一个jquery提示框特效,黑色风可,且提示框是圆角形状,点击页面中间的几个文字,提示框信息就会动态显示,CSS和JS部分代码比较多。
先来看看运行效果如下:

具体代码如下:
jQuery实现的非常人性化的提示信息框效果
script>
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(' '+logName+'
')
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('
'+msg+'')
.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>
希望本文所述对大家的jquery程序设计有所帮助。