JavaScript and the DOM

jQuery Selectors

With plain JavaScript we selected an HTML element with this code:


With jQuery we can select the same element with:

  1. We can wrap any CSS selector, like class, id, or tag, with $('.example-class') to select it with jQuery.

  2. The selectors jQuery uses are the exact same as CSS selectors. For instance, if there's an element with a class of supporting-text, you could select it with $('.supporting-text'). Another example, if an element had an id of 'header', you could select it with $('#header').

Community Forums
Get help and ask questions in the Codecademy Forums
Report a Bug
If you see a bug or any other issue with this page, please report it here.