Thông tin tài liệu
[...]... sample1.html jQuery will change this > >jQuery. > jQuery( 'a').text( 'jQuery' ).attr('href', 'http://www .jquery. com'); Notice that in this HTML document we are using jQuery to... below Sample: sample9.html jQuery( function($){ // Pass jQuery a function // Pass jQuery a string of HTML $('').appendTo('body'); // Pass jQuery an element reference $(document.createElement('a')).text( 'jQuery' ).appendTo('p'); // Pass jQuery a CSS expression $('a:first').attr('href',... Sample: sample14.html jQuery if (jQuery( 'a').get(0)) { // Is there an element in the set? jQuery( 'a').attr('href', 'http://www .jquery. com'); } if (jQuery( 'a').length) { // Check the length of the set Can also use size() jQuery( 'a').attr('title', 'jQuery' ); } ... src="http://ajax.googleapis.com/ajax/libs /jquery/ 1.7.2 /jquery. min.js"> (function ($) { jQuery( '') append('jQuery. comjQuery Documentation') find('a:first') attr('href', 'http://www .jquery. com') end() find('a:eq(1)') 32 .attr('href', 'http://docs .jquery. com') end() find('a') click(function () { return confirm('Leave this page?'); }) end() appendTo('body'); }) (jQuery) ; ... third DOM object on the page Sample: sample13.html jQuery. com jQuery. com jQuery. com (function ($) { var arrayOfAnchors... a child element, whereas jQuery' s mouseenter does not Sample: sample10.html jQuery. com jQuery. com jQuery. com 23 (function ($) { $('a').mouseenter( function () { alert(this.id); }); }) (jQuery) ; ... Sample: sample12.html jQuery. com (function ($) { // Using DOM node properties to set the title attribute $('a').get(0).title = 'jQuery. com'; // Manipulation of DOM element using jQuery methods $('a').attr('href', 'http://www .jquery. com'); }) (jQuery) ; 25... sample6.html (function ($) { $('a').text( 'jQuery' ) // Sets text to jQuery, and then returns $('a') .attr('href', 'http://www .jquery. com/') // Sets the href attribute and then returns $('a') .addClass( 'jQuery' ); // Sets class and then returns $('a') }) (jQuery) ... selecting elements using DOM references: jQuery( 'p > a') or jQuery( ':first') and jQuery( document.body) Create HTML on the fly by passing HTML string structures or DOM methods that create DOM elements: jQuery( '') or jQuery( document.createElement('div') A shortcut for the ready() event by passing a function to the jQuery function: jQuery( function($){ /* Shortcut for ready() */ }) Each... you read jQuery semantics The term "jQuery function" refers to the jQuery constructor function (jQuery( ) or alias $()) that is used to create an instance of the jQuery object The term "wrapper set" refers to DOM elements that are wrapped within jQuery methods Specifically, this term is used to refer to the elements selected using the jQuery function You may have heard this referred to as a "jQuery collection." . before including jQuery 18
Using a hosted version of jQuery 18
Executing jQuery code when DOM is parsed without using ready() 19
Grokking jQuery chaining. to jQuery. fn object to become jQuery methods 84
Inside a plugin, this is a reference to the current jQuery object 85
Using each() to iterate over the jQuery
Ngày đăng: 18/03/2014, 01:20
Xem thêm: jQuery Succinctly doc