0

How would I do this in mootools? I have an Unordered list items that I want to add classes to each of them But there are some list item that I want to exclude in adding a new class.

here's my markup

<div id="header">
     <ul id="mainnav">
        <li class="item1"><a href="#">Home</a></li>
        <li class="item2"><a href="#">About</a></li>
        <li class="item3"><a href="#">Product</a></li>
        <li class="item4"><a href="#">Contact</a></li>
        <li class="item4"><a href="#">Forum</a></li>
     </ul>
</div>

here's something I want to achieve using mootools

<div id="header">
     <ul id="mainnav">
        <li class="item1"><a href="#">Home</a></li>
        <li class="item2"><a href="#">About</a></li>
        <li class="item3 NewClass"><a href="#">Product</a></li>
        <li class="item4"><a href="#">Contact</a></li>
        <li class="item4 NewClass"><a href="#">Forum</a></li>
     </ul>
</div> 

Thanks!

1 Answer 1

2

Assuming the second item4 is item5, ( though I'm a jQuery user ) but a quick look at the API says it should be like this:

$$('.item3', '.item5').addClass('newClass')
Sign up to request clarification or add additional context in comments.

2 Comments

THANK YOU meder, this answer to my question. :)
don't forget to click on the big check box if someone answers your question :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.