本文发表在 rolia.net 枫下论坛(function($,undefined){
$.fn.myFlashMessage = function(params) {
//use extend to merge input parameters and defaults.
//use an empty object literal first as it is
//overwritten by the extend method.
var settings = $.extend(
{},
{
levelClass : 'info',
animationSpeed : 1000
},
params);
if(typeof(settings.message) === 'string') {
//our jQuery object
this
//replace html with the message
.html(settings.message)
//add the appropriate class for the message level
.addClass(settings.levelClass)
//click to close the message.
//remove the handler once it has run.
.one('click',function(){
$(this)
.slideUp(settings.animationSpeed, function(){
//this will remove the Class once
//slideUp is complete
$(this).removeClass(settings.levelClass);
});
})
.slideDown(settings.animationSpeed);
}
}
})(jQuery);更多精彩文章及讨论,请光临枫下论坛 rolia.net
$.fn.myFlashMessage = function(params) {
//use extend to merge input parameters and defaults.
//use an empty object literal first as it is
//overwritten by the extend method.
var settings = $.extend(
{},
{
levelClass : 'info',
animationSpeed : 1000
},
params);
if(typeof(settings.message) === 'string') {
//our jQuery object
this
//replace html with the message
.html(settings.message)
//add the appropriate class for the message level
.addClass(settings.levelClass)
//click to close the message.
//remove the handler once it has run.
.one('click',function(){
$(this)
.slideUp(settings.animationSpeed, function(){
//this will remove the Class once
//slideUp is complete
$(this).removeClass(settings.levelClass);
});
})
.slideDown(settings.animationSpeed);
}
}
})(jQuery);更多精彩文章及讨论,请光临枫下论坛 rolia.net