3 Temmuz 2012 Salı

jQuery Syntax Examples


jQuery is a JavaScript Library.
jQuery greatly simplifies JavaScript programming.
jQuery is easy to learn.

jQuery Syntax Examples

$(this).hide()
Demonstrates the jQuery hide() method, hiding the current HTML element.
$("#test").hide()
Demonstrates the jQuery hide() method, hiding the element with id="test".
$("p").hide()
Demonstrates the jQuery hide() method, hiding all
elements.
$(".test").hide()
Demonstrates the jQuery hide() method, hiding all elements with class="test".

The Document Ready Function

You might have noticed that all jQuery methods, in our examples, are inside a document.ready() function:
$(document).ready(function(){

   // jQuery functions go here...

});
This is to prevent any jQuery code from running before the document is finished loading (is ready).
Here are some examples of actions that can fail if functions are run before the document is fully loaded:
  • Trying to hide an element that doesn't exist
  • Trying to get the size of an image that is not loaded


Hiç yorum yok:

Yorum Gönder