jQuery Combination selector
Notes:
jQuery Combination selector :
To select HTML element(s) as specifically as possible, we use jQuery combination selector.
Note: For more specific selection of HTML element(s), In CSS it is possible to combine selectors, which is called as CSS combination selector. To combine selectors; we place selectors one beside another without any separator.
i.e. selector1selector2…
Ex:
tagselectorclassselector,
tagselectoridselector,
tagselectoridselectorattributeselector etc.
Syntax of jQuery Combination selector:
$(“CSS combination selector”).action(parameters);
To the jQuery function, if we pass the CSS combination selector then it is called as jQuery combination selector. I.e. a jQuery function with CSS combination selector as a parameter is called as jQuery combination selector.
EX:
$(“selector1selector2…”).action(parameters);
To the jQuery function, if we pass multiple selectors without any separator then it is called as jQuery combination selector
Ex:
$("h1.redBorder").css("border","2px bouble red");
It selects any h1 element on the page, whose class attribute value set to redBorder and applies the border of 2px double red
$("p.redBorder").css("border","2px solid red");
It selects any p element on the page, whose class attribute value set to redBorder and applies the border of 2px solid red
$("p.redBorder[align=right]").css("border","2px dotted red");
It selects any p element on the page, whose class attribute value set to redBorder, aligned right and applies the border of 2px dotted red.
Interview Questions: