JQuery Programmer Question:
What are jQuery Selectors? Give some examples?
Answer:
1. jQuery Selectors are used to select one or a group of HTML elements from your web page.
2. jQuery support all the CSS selectors as well as many additional custom selectors.
3. jQuery selectors always start with dollar sign and parentheses: $().
4. There are three building blocks to select the elements in a web document.
1) Select elements by tag name
Example : $(div)
It will select all the div elements in the document.
2) Select elements by ID
Example : $("#xyzid")
It will select single element that has an ID of xyzid.
3) Select elements by class
Example : $(".xyzclass")
It will select all the elements having class xyzclass.
2. jQuery support all the CSS selectors as well as many additional custom selectors.
3. jQuery selectors always start with dollar sign and parentheses: $().
4. There are three building blocks to select the elements in a web document.
1) Select elements by tag name
Example : $(div)
It will select all the div elements in the document.
2) Select elements by ID
Example : $("#xyzid")
It will select single element that has an ID of xyzid.
3) Select elements by class
Example : $(".xyzclass")
It will select all the elements having class xyzclass.
Previous Question | Next Question |
How to set the style property of an element using jQuery? | How to remove set of matched elements using jQuery? |