Selecting by ID (Must know)
In this section we'll learn how to select an element by its ID and apply the same border seen previously.
How to do it...
This task can be achieved by performing the following instructions:
- Create a copy of the
template.htmlfile and rename it as
- Inside the
<body>tag, add the following HTML markup:
<h1 id="title">The Id selector</h1> <div id="container"> This example shows you how to use the Id selector. <p id="description">As you can see, this time the border is applied only to the h1 element because of its id.</p> <span id="note">Hey, I'm a note</span> </div>
- Edit the
<head>section as we did in the previous chapter, but this time add this script after the jQuery library instead:
<script> $(document).ready(function() ...