views:

13

answers:

1

The situation is that I want to add a class 'display-none' to li eliment which has a child eliment 'a'

<li class="mostread">
    <a href="/intranet/Admin/Error-Pages/404.html" class="mostread">404</a>
</li>

i.e., if li class mostread has child element a href="/intranet/Admin/Error-Pages/404.html" and class mostread then add class 'display-none' to the parent li.

After processing it would look like

<li class="mostread display-none">
    <a href="/intranet/Admin/Error-Pages/404.html" class="mostread">404</a>
</li>
+1  A: 

Try this:

$$('li a.mostread').each(function(el){
    if ('/intranet/Admin/Error-Pages/404.html' === el.get('href') &&
        'li' === el.getParent().get('tag')) {

        el.addClass('display-none');
    }
});

Note that this is using mootools 1.2

sheeks06