The All selector (Must know)
With our template in place, we can start diving into the world of jQuery selectors. A selector is a string that allows you to retrieve DOM's elements. The first selector we'll look at is the All
(or Universal) selector. We'll use it to apply a border to all of the page's elements.
How to do it...
To achieve our goal, perform the following steps:
- Create a copy of the
template.html
file and rename itthe-all-selector.html
. - Inside the
<body>
tag, add the following HTML markup:<h1>The all selector</h1> <div> This example shows how to use the All selector. <p>As you can see, it doesn't matter we're different tags, we all have the border applied.</p> <span>Every tag has the border, even the body, the html and the head tag!</span> ...
Get Instant JQuery Selectors 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.