jQuery is a fast and concise JavaScript framework. It is another excellent JavaScript code library (or JavaScript framework) after Prototype. The purpose of jQuery's design is "write less, do more", which means writing less code and doing more things. It encapsulates common JavaScript function codes, provides a simple JavaScript design pattern, and optimizes HTML document operations, event processing, animation design and Ajax interaction. We have collected the "Boolean Education jQuery Practical Video Tutorial", hoping to help everyone learn jQuery better.
Video playback address: http://www.php.cn/course/319.html
Related topic recommendations: "jquery practical video"
Summary of jquery difficulties:
1 How to pass parameters in jquery binding event
$("#btn").bind("click",{"id":"111","name":"aaa"}, getData); function getData(d) { alert(d.data.id); alert(d.data["name"]) }
2 How to call in setTimeout Object methods
setTimeout( function(self) { return function() { alert(self);//这里面用self代替this } }(this), 1000);
3 The difference between this and $(this)
Concept:
This indicates that the current context object is an html object, and you can call the attributes and properties owned by the html object The context object represented by the method, $(this), is a jquery context object, which can call jquery's methods and attribute values.
What does $() generate? In fact, $()=jquery() means that it returns a jquery object.
Usually we use $() directly for simplicity. In fact, this function omits a parameter context. Select the matching object based on the selector, that is, $(selector, context), and return it in the form of a jQuery wrapper set. Context can be a collection of Dom objects or a jQuery packaging set. If passed in, it means that the matching object is to be selected from the context. If it is not passed in, it means that the scope is the document object (that is, all objects on the page), that is, $(selector)=$(selector, document).
This refers to the html object that calls the function.
Example:
$("#textbox").hover( function() { this.title = "Test"; }, fucntion() { this.title = "OK”; } );
This here is actually an Html element (textbox), and this is in js. The textbox has a text attribute, so there is no problem in writing it this way.
$("#textbox").hover( function() { $(this).title = "Test"; }, function() { $(this).title = "OK"; } );
$(this) here is a JQuery object, and the jQuery object does not have a title attribute, so writing this is wrong.
Summary:
This means that the current context object is an html object, and you can call the properties and methods owned by the html object.
$(this), the context object represented is a jquery context object, which can call jquery methods and attribute values.
4 app font adaptive
//使用rem策略,不断更新html的fontsize (function(){ function sizeHtml(){ var size = $(window).width()/16; size = size>40?40:size; $("html").css("font-size",size+"px"); } sizeHtml(); $(window).resize(function(){ sizeHtml(); }) })()
The above is the detailed content of Boolean education jQuery practical video material sharing. For more information, please follow other related articles on the PHP Chinese website!