jQuery group selector
Notes:
jQuery group selector :
There are situations where differ ent selectors share similar styles. To reduce code redundancy in CSS it is possible to group selectors. To create group selector; we place selectors one beside another with a comma separator. i.e. selector1,selector2,….
Note: The comma separated list of CSS selectors is called as group selector in CSS.
Ex for CSS group selector:
tagselector,classselector
tagselector,idselector
tagselector,idselector,attributeselector etc.
Syntax of jQuery group selector:
$(“CSS group selector”).action(parameters);
To the jQuery function, if we pass the CSS group selector then it is called as jQuery group selector. I.e. a jQuery function with CSS group selector as a parameter is called as jQuery group selector.
I.e.:
$(“selector1,selector2,…”).action(parameters);
To the jQuery function, if we pass comma separated list of CSS selectors then it is called as jQuery group selector
Ex:
$("h1,p").css("border","2px solid red");
It selects any HTML element on the page, which has the tag name h1 or p; applies the border of 2px solid red
Ex:
$("p,.solidborder,#redBorder").css("border","2px solid red");
It selects any HTML element on the page, which has the tag name p, class attribute value set to solidborder or an id attribute value set to redBorder; applies the border of 2px solid red.
Interview Questions: