All JQuery functions are in a document ready function:
$ (document). Ready (function () {---jQuery functions go to here----5});
This is to prevent the document from running JQuery code before it is fully loaded (ready).
JQuery element Selector
JQuery uses CSS selectors to select HTML elements.
$ ("P") select the <p> element.
$ ("P.intro") selects all the <p> elements of the class= "Intro".
$ ("P#demo") selects all <p> elements of the id= "demo".
JQuery Property Selector
JQuery uses an XPath expression to select an element with a given property.
$ ("[href]") selects all elements with an href attribute.
$ ("[href= ' # ']") selects all elements with an HREF value equal to "#".
$ ("[href!= ' # ']") selects all elements with an HREF value that is not equal to "#".
$ ("[href$= '. jpg ']") selects all elements with an href value ending with ". jpg".
JQuery CSS Selector
The JQuery CSS selector can be used to change the CSS properties of HTML elements.
The following example changes the background color of all p elements to red:
Instance
1 $ ("P"). CSS ("Background-color", "Red");
First day of jquery