JQuery study diary

1. All method or function plug-ins need to end with a semicolon, and you can even add a sub-head to the plug-in header to avoid the impact of other people's irregular code on the plug-in.

2. Framework for writing plugins

;(function($){

/*code*/

})(jQuery);

3. Smart settings for plugin defaults

function foo(options){
options=jQuery.extend({
name:"bar",
length:5,
dataType:"xml"
}, options);
}

4. [] Methods that can be used to fetch objects

$(this)[isTrue?"addClass":"removeClass"]("selected")//方法

4. js has no block scope

for(var i=0;i<10;i++){

console.log(i);

}

alert(i);// A dialog box of 10 will pop up outside the loop


5. js retains the method of fields and windows. Before using an open() as the function name, it cannot be called no matter what. Later found that open() is window.open(), which has been used

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326068329&siteId=291194637