Lab - Dom Walk
Find the flags
by Rob Lardy
HTML
<div id="container">
<h1>Find the flag elements.</h1>
<p>There are three flags ("FLAG") in the content below. Find them and move their containing elements into the #bucket element.</p>
<div class="main">
<ul>
<li>One</li>
<li>FLAG 1</li>
<li>Three</li>
</ul>
<div id="articles">
<article class="new">
<h3>Article 1</h3>
<p>This is <a href="#">some</a> body content</p>
<p>This is some body content <a class="flag" href="#">FLAG 2</a></p>
</article>
<article class="new">
<h3>Article 2</h3>
<p>This is some body content</p>
</article>
<article>
<h3>Article 3</h3>
<p>This is some body content</p>
</article>
<div class="footer">
<div>
<div>
<div></div>
<div>
<div>FLAG 3</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div id="bucket">
<h2>Drop your flags here...</h2>
</div>
</div>
JavaScript
// Using jquery
// select each of the 3 elements that contain "FLAG"
//
// Log the result of each flag found to the console or
// BONUS POINTS: move the flag into the #bucket div
//
// Expect to use:
// $(selector)
// console.log()
// for bonus points
// .append() or
// .prepend()
// get flag 1
var firstflag = $("ul".'li:nth-child(2))
// get flag 2
// get flag 3