2. • What is JQuery
• is free, open source software licensed under
the MIT License. jQuery's syntax is designed to
make it easier to navigate a document,
selectDOM elements, create animations,
handle events, and develop Ajax
applications. jQuery also provides capabilities
for developers to create plug-inson top of the
JavaScript library. This enables developers to
create abstractions for low-level interaction
and animation, advanced effects and high-
level, theme-able widgets. The modular
approach to the jQuery library allows the
creation of powerful dynamic web pages
and web applications
JQuery
3. • Features of Jquery
• 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 1–3)
• DOM manipulation based on CSS selectors that uses node elements name and node elements
attributes (id and class) as criteria to build selectors
• 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.
JQuery
4. • 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.
jQuery has a CDN sponsored by Media
Temple(previously at Amazon).
Google and Microsoft host it as well.
The JQuery Library
5. <script type="text/javascript"
src="jquery.js"></script>
• It is also possible to include jQuery directly
from content delivery networks.
<script
src="http://ajax.googleapis.com/ajax/libs/j
query/1.9.1/jquery.min.js"></script>
Examples of How to include
JQuery
6. • 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.
Usage Styles
7. • This is an example of a jquery being use to
add manipulation of multiple DOM nodes
beginning in a $ function being called with
a CSS selector string which results in a
Jquery object referencing matching
elements in an HTML
Examples of a Jquery
8. • 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"
• $("div.test").add("p.quote").addClass(
"blue").slideDown("slow");
Examples of a JQuery
9. • the methods prefixed with $. are
convenience methods or affect global
properties and behaviour.
• $('select#carmakes').append($('<option
/>').attr({value:"VAG"}).append("Volkswage
n"));
Examples of a JQuery
10. • This writes "234" to the document.
• $.each([1,2,3], function() {
document.write(this + 1); });
Examples of a JQuery
11. • This example posts the
data name=John and location=Boston to example.ph
p 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.
$.ajax({ type: "POST", url: "example.php", data:
"name=John&location=Boston" }).done( function(msg)
{ alert( "Data Saved: " + msg ); }).fail( function(
xmlHttpRequest, statusText, errorThrown ) { alert( "Your
form submission failed.nn" + "XML Http Request: " +
JSON.stringify( xmlHttpRequest ) + ",nStatus Text: " +
statusText + ",nError Thrown: " + errorThrown ); });
Examples of a JQuery
12. • 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
web that 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 64emulator.
jQuery plug-ins