我想知道这三种方法中最好的方法,也许为什么?
1)
(function($) {
var methods = {
init : function(options) {
if( this.length ){
var settings = {
something : 'fast'
};
return this.each(function(){
if ( options ) {
$.extend( settings, options );
}
var $el = $(this),
/* some variables */
$selector1 = $el.find('container'),
count = $selector1.length,
$selector2 = $el.find('pictures');
/* do something e.g.*/
doSomething1();
doSomething2();
function doSomething1() {
$selector1.css('width' , '300px');
};
function doSomething2() {
$selector2.each(function(i) {
//do something
});
};
});
}
},
update : function() …Run Code Online (Sandbox Code Playgroud)