jquery封装插件

这两种方式等效:


/**
用法
$("#bb").tooltip1();
$("#bb").tooltip2();
*/


(function ($) {
$.fn.tooltip1 = function( options ) {
var $this = $(this);
var txt = $this.html();
alert(txt);
};


$.fn.extend({
tooltip2:function( options ) {
var $this = $(this);
var txt = $this.html();
alert(2);
}
})(jQuery);

 
原文地址:https://www.cnblogs.com/time-on/p/7843489.html