Top Banner
JQUERY
14
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
  • 1. JQUERY

2. jQuery a fast, small, and feature-rich JavaScript library. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers. With a combination of versatility and extensibility, jQuery has changed the way that millions of people write JavaScript. 3. Who is using jQuery? 4. Other jQuery foundation project 5. jQuery features DOM element selections using the multi-browser open source selector engine Sizzle, a spin-off of the jQuery project DOM traversal and modification (including support for CSS 13) DOM manipulation based on CSS selectors that uses node elements name and node elements attributes (id and class) as criteria to build selectors 6. Events Effects and animations AJAX Extensibility through plug-ins Utilities - such as user agent information, feature detection Compatibility methods that are natively available in modern browsers but need fall backs for older ones - For example the inArray() and each() functions. Multi-browser (not to be confused with cross- browser) support. 7. Including the library The jQuery library is a single JavaScript file, containing all of its common DOM, event, effects, and Ajax functions. It can be included within a web page by linking to a local copy, or to one of the many copies available from public servers. It is also possible to include jQuery directly from content delivery networks. 8. Usage styles jQuery has two usage styles: Via the $ function, which is a factory method for the jQuery object. These functions, often called commands, are chainable as they all return jQuery objects. Via $.-prefixed functions. These are utility functions, which do not act upon the jQuery object directly. 9. Typically, access to and manipulation of multiple DOM nodes begins with the $ function being called with a CSS selector string, which results in a jQuery object referencing matching elements in the HTML page. This node set can be manipulated by calling instance methods on the jQuery object, or on the nodes themselves. For example: $("div.test).add("p.quote").addClass("blue").slideDown("slow"); 10. This line finds the union of all div tags with class attribute test and all p tags with CSS class attribute quote, adds the class attribute blue to each matched element, and then increases their height with an animation. The $ and add functions affect the matched set, while the addClass and slideDown affect the referenced nodes. Besides accessing DOM nodes through jQuery object hierarchy, it is also possible to create new DOM elements if a string passed as the argument to $() looks like HTML. For example, this line finds an HTML SELECT element with ID="carmakes", and adds an OPTION element with value "VAG" and text "Volkswagen": $('select#carmakes').append($(').attr({value:"VAG}).append("Volkswagen")); 11. The methods prefixed with $. are convenience methods or affect global properties and behaviour. For example, the following is an example of the iterating function called each in jQuery This writes "234" to the document. $.each([1,2,3], function() { document.write(this + 1); }); 12. It is possible to perform browser-independent Ajax queries using $.ajax and associated methods to load and manipulate remote data. This example posts the data name=John and location=Boston to example.php on the server. When this request finishes successfully, the success function is called to alert the user. If the request fails, it will alert the user to the failure, the status of the request, and the specific error. 13. jQuery plug-ins jQuery's architecture allows developers to create plug-in code to extend its functionality. Currently there are thousands of jQuery plug-ins available on the webthat cover a wide range of functionality such as Ajax helpers, web services, datagrids, dynamic lists, XML and XSLT tools, drag and drop, events, cookie handling, modal windows, and even a jQuery- based Commodore 64 emulator. 14. Reference: http://jquery.com/ http://en.wikipedia.org/wiki/JQuery