jQuery selectors
Notes:
JQuery Selectors :
First step in learning jQuery is learning “how to select HTML element(s) using jQuery” as efficiently as possible, then “how to add styles, effects, animations, events etc.” to them
To select HTML element(s) JQuery function accepts a “CSS selector”.
Syntax:
jQuery(“CSS selector”).action(parameters);
OR
$(“CSS selector”).action(parameters);
CSS Selector: is a string used to select or target HTML element(s) available on page.
To select HTML element(s) on the page as much as specifically and as much as generically;
CSS provides wide variety of selectors.
Types of CSS Selectors
1. Tag selector (<tagname> tagname{} )
2. Class selector (<tagname class=”classname”> .classname{} )
3. ID selector (<tagname id=”idname”> #idname{} )
4. Group selector ( slct1, slct2{} )
5. Contextual selector
a. Descendent selector( slct1 slct2{} )
b. Direct Child selector( slct1 > slct2{} )
c. Adjacent sibling selector( slct1 + slct2{} )
d. General sibling selector( slct1 ~ stct2{} )
6. Attribute selector (<tagname attribute=””> [attributename]{} )
7. Pseudo classes ( slct:pseudoclass{} )
8. Pseudo elements ( slct::pseudoelement{} )
9. Universal selector( *{} )
Interview Questions: