Explore 100's Of Free Video Tutorials

Keep Learning, Keep Coding & Keep Sharing

jQuery id selector

Notes:

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

Ex:
$("#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: