Instruction: Provide examples of selecting elements by ID, class, and tag name using jQuery.
Context: This question assesses the candidate's ability to manipulate the DOM by selecting elements using different selectors in jQuery.
Official answer available
Preview the opening of the answer, then unlock the full walkthrough.
To begin with, selecting an element by its ID in jQuery is straightforward. You use the # symbol followed by the ID of the element. For example, if you have an element with the ID loginButton, you would select it in jQuery like so:
$('#loginButton')...
easy
easy
easy
medium
medium
medium