views:

175

answers:

1

Hi,

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  A: 

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')
meder
THANK YOU meder, this answer to my question. :)
Pennf0lio
don't forget to click on the big check box if someone answers your question :)
meder