Given the following HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<div class="header">
</div>
<section id="container">
<ul>
<li class="first">one</li>
<li class="second">two</li>
<li class="third">three</li>
</ul>
<ol>
<li class="first">one</li>
<li class="second">two</li>
<li class="third">three</li>
</ol>
</section>
<div class="footer">
</div>
</body>
</html>
Write the code necessary to do the following:
- Select the
section
with an id ofcontainer
without usingquerySelector
. - Select the
section
with an id ofcontainer
usingquerySelector
. - Select all of the list items with a class of “second”.
- Select a list item with a class of third, but only the list item inside of the
ol
tag. - Give the
section
with an id ofcontainer
the text “Hello!”. - Add the class
main
to thediv
with a class offooter
. - Remove the class
main
on thediv
with a class offooter
. - Create a new
li
element. - Give the
li
the text “four”. - Append the
li
to theul
element. - Loop over all of the
li
s inside theol
tag and give them a background color of “green”. - Remove the div with a class of
footer
.
Solutions
You can find solutions to the exercises here
When you’re ready, move on to Introduction to Events