jQuery id selector


jQuery ID selector :

To select html element(s) by their id attribute value, we use jQuery id selector

Syntax of jQuery ID selector:
$(“CSS ID selector”).action(parameters);
To the jQuery function, if we pass the CSS ID selector then it is called as jQuery ID selector
I.e. a jQuery function with CSS ID selector as a parameter is called as jQuery ID selector

$("#firstp").css( {"border":"2px solid blue"} );
It selects any HTML element whose id attribute value is set to “firstp” and applies the border of 2px solid blue
Note: in CSS hash(#) symbol indicates ID selector and id attribute value should be unique

Interview Questions: