$.fn.Tip = function(option) {
return this.each(function(){
var e = $(this),
data = e.data(‘tip’),
options = typeof option == “object” && option;
if (!data) e.data(“tip”, new Tip(this,options));
if (typeof option == ‘string’) data[option]();
});
}
}(window.jQuery);
css样式
.tip {
position: absolute;
padding: 3px;
background: #efefef;
border-radius: 2px;
top: 0px;
left: 0px;
}
.tip .tip-inner {
background: #fafafb;
border: 1px solid #d8d8d8;
}
.tip .tip-inner h3 {
font-size: 14px;
padding: 5px;
border-bottom: 1px solid #eee;
}
.tip .tip-inner .tip-container {
padding: 5px;
}
以上就是本文的所有内容了,小伙伴们对如何编写jQuery插件是否有了新的 认识了呢,希望大家能够喜欢本文。










