2. Selecting Elements the jQuery Way
One of jQuery’s specialties is letting you select page elements so you can work on them.
You will often need to select page elements in online work. The selection capabilities of browsers are minimal and mostly involve the JavaScript getElementByID
function, which requires you to add an ID value to any element you want to select (making selection of multiple items difficult, or at least time consuming).
CSS offers a much stronger set of tools for selecting page elements to set styles, and jQuery adopts many of the CSS selectors. Using the jQuery selectors lets you select page elements so you can work on them in JavaScript, not just with CSS styles.
You saw some basic selectors in the previous chapter, but ...
Get jQuery: Visual QuickStart Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.