Jquery 插件开发
;(function ( $, window, document, undefined ){
'use strict';
var pluginName='pluginName';
$.extend({ log: function (logdata) { console.log(logdata);} });
function Plugin( element, options )
{
$.log(element);$.log(options);
}
$.fn[pluginName] = function ( options ) {
return this.each(function () {
if (!$.data(this, "plugin_" + pluginName)) {
$.data(this, "plugin_" + pluginName, new Plugin( this, options ));
}
});
};
})( jQuery, window, document );
标准插件开发
$.extend $.fn.extend
<strong>Use:</strong>
$('#div').pluginName({});