The jQuery punctuation is appropriately customized for selecting HTML components and perform some action on the element(s). With jQuery you select HTML components and perform "actions" on them.
Syntax : $(selector).action()
You have to define all jquery methods inside a document ready event:
$(document).ready(function(){
//Snippet code goes here
});
This is to keep any jQuery code from running before the document is done loading.
Here are a few examples that can come up short if methods are keep running before the document is fully loaded:
Syntax : $(selector).action()
- A $ sign to define jQuery.
- A (selector) to find HTML elements.
- A jQuery action() to be performed on the element(s).
- $(this).hide() - hides the current element.
- $("p").hide() - hides all <p> elements.
- $(".hubkart").hide() - hides all elements with class="hubkart".
- $("#hubkart").hide() - hides the element with id="hubkart".
You have to define all jquery methods inside a document ready event:
$(document).ready(function(){
//Snippet code goes here
});
This is to keep any jQuery code from running before the document is done loading.
Here are a few examples that can come up short if methods are keep running before the document is fully loaded:
- Attempting to hide a component that is not made yet
- Attempting to get the size of a picture that is not loaded yet
Post a Comment