What is jQuery


jQuery is a fast, small, and feature-rich client side JavaScript library.


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.

When to use jQuery

Whenever html manipulation is needed. Issuing ajax requests registering for DOM events, etc.



When not to use jQuery

When building sophisticated single page web applications.
For this kind of tasks a more elaborate client library will be needed like KnockoutJS, Backbone or AngularJS.

   

Learning jQUERY

A lot of resources in the jQuery site


A good set of examples can be found at:

http://learn.jquery.com/






Working with DOM elements

Example 1 -Hide an element with id "textbox“

//javascript
document.getElementById('textbox').style.display = "none";

//jQuery
$('#textbox').hide();


Example 2 - create a <h1> tag with "my text"

//javascript
var h1 = document.CreateElement("h1");
h1.innerHTML = "my text";
document.getElementsByTagName('body')[0].appendChild(h1);

//jQuery
$('body').append( $("<h1/>").html("my text") );

DOM EVENT HANDLING


// dissapearing links
$( "a" ).click(function( event ) {
    event.preventDefault();
    $( this ).hide( "slow" );
});

AJAX Requests


$.get( "myhtmlpage.html", function() {
  // issues an AJAX http get for the myhtmlpage.html file
});

jQuery

By Saar Yahalom

jQuery

null

  • 1,335