Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript jQuery Basics (2014) Creating a Mobile Drop Down Menu Perform: Part 3

Mike Me
Mike Me
5,148 Points

Can't understand.

        <ul>
            <li class="selected"><a href="index.html">Home</a></li>
            <li><a href="about.html">About</a></li>
            <li><a href="contact.html">Contact</a></li>
            <li><a href="support.html">Support</a></li>
            <li><a href="faqs.html">FAQs</a></li>
            <li><a href="events.html">Events</a></li>
        </ul>

See that code above? only one

<li>

has class "selected", explain please how can we apply to other li's with the same class name they do not have. How they their the same class?

if($anchor.parent().hasClass("selected")) {
    $option.prop("selected", true);
  }

1 Answer

Mike,

Take a look at this answer by Samuel Webb to someone else's similar question: click here.

Samuel Webb's explanation clarified the same issue for me.