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

// You can use:
//     getElementById
//     getElementsByTagName
//     getElementsByClassName
//     querySelector
//     querySlectorAll
// and all the parent, child and sibling selectors

// get flag 1
// stored in the first ul, second li


// get flag 2
// stored in the first article, last p, the a


// get flag 3
// stored in the last div p