Mootools add a class to 'a' href="something"
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 di开发者_开发技巧splay-none">
<a href="/intranet/Admin/Error-Pages/404.html" class="mostread">404</a>
</li>
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
精彩评论