Jquery brief Introduction – Basic of Jquery
Advantages of J query –
– Easy to use
– Ajax capabilities
– Large pool of inbuilt methods
– easy to use Dom manipulation and traversal
jquery execute when dom is ready –
$ is an alias for jquery, we can replace it by our choice too like
We can use multiple document ready function on same page for different manipulation. We can also use other js libraries with jquery. We used jQuery.noConflict() to replace $ sign in jquery. We use this when used another library with jquery because other library also can use $ sign so not to have conflict jQuery.noConflict should be used,
var $j = jQuery.noconflict();
Diff between body onload() and document.ready in jquery?
1- document.ready can be used multiple time in a page but body onload() can be used only once.
2- document.ready executes when Dom is ready but body onload() executes when everything is loaded on page.
jquery comes in 2 different versions production and deployment. Deployment version also know as minified veriosn . .js and .min.js both are same in functionality only size matters.
jquery selectors –
To do the Dom manipulation we need elements and need to find them. We used jquery selector to find HTML elements-
1- name selector – select all element which match given name.
2- class selector – select all element with given class name, $(“.classname”)
3- id selector -select 1 element which match the given id $ (“#nid”)
4- * selector – select all element – $(“div”)
keep in mind – last selector always executed first.
jquery will find all element with class name myclass and then it will reject all element which are not in “p#elmid”
For eg –
document.getElementByID(‘name’) or (“#name”) in this document.getElementByID will execute first because jquery will internally call document.getElementByID(‘name’) function first.