jQuery Syntax
All jquery methods are inside a document ready event:
$(document).ready(function(){
..... jQuery functions
});
OR
$(function(){
..... jQuery functions
});
this prevents the jQuery code to execute before the document is loaded or ready.
the basic syntax of jQuery is:
$(selector).action();
$ -> sign to define jQuery.
(selector) -> to find HTML elements
.action () -> action to be performed on the HTML element(s).
Example:
$(this).hide(); -> hides the current element
$("p").hide(); -> hides all <p> elements
$("h2").hide(); -> hides all <h2> elements
$(".myclass").hide() -> hides all elements with class="myclass"
$("#myid").hide() -> hides all elements with id="myid"
No comments:
Post a Comment