What Already Know?
Before you jQuery, basics following elements
What is jQuery?
The jQuery library contains the following things:
• HTML/DOM manipulation
• CSS manipulation
• HTML event methods
• Effects and animations
Why jQuery needed?
Many of the famous companies’ uses jQuery, like:
Will be jQuery work in all browsers?
The jQuery team knows all issues about cross-browser CBT, and so they are constructed in that way.
jQuery code or libraries will run exactly same in all browsers, including Internet Explorer 6!
With jQuery HTML elements are selected and performed "actions" on them.
A “$” sign to defines jQuery
A (selector) used to find HTML elements
A jQuery action() tells action to be performed on elements
$(this).hide() - hide current element.
$("p").hide() - hide all <p> elements.
$(".abc").hide() - hide all elements with class="abc".
$("#xyz").hide() - hide element with id="xyz".
The Document Ready Event in jQuery:-
You may know that all jQuery methods in example, are inside a document ready event:
// jQuery methods 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 methods are run before the document is fully loaded:
Trying to hide an element that is not created yet.
Trying to get the size of an image that is not loaded yet.