I see the method of getting second class name with jquery but how do I do it in mootools , my element is <li class="parent active">
I need to match full class name like li.parent.active and adjust height if that class is present I tried
$$('li').hasClass('parent active') or getProperty but all of them return true even if active is not present, if I add .parent.active I get
The expression is not a legal expression. now I must support mootols 1.1 ,1.2 ,1.3 working on CMS here so I started with the ugly one 1.1 version
this is how is actually needed
var holderdiv =$('mymenu');
if($$('li.parent.active')){holderdiv.setStyle({'height':'50px'});
if($$('li.parent.active') == true)returns true as in, it’s truthy (defined, not null).if you mean to say: is there at least one child element that has .parent and .active, you can do:
if they are not children of holderdiv just do
document.getElementorwhateverElObj.getElementinstead.this will likely break in 1.11 due to old xpath stuff.
one way to do it so it works in all versions would be this (though you should only do this if MooTools.version is wrong due to performance cost of double loops):
the
.somewill run through allli.parentuntil it finds one that matches the condition (hasClass("active")) and then return boolean true else, false.http://jsfiddle.net/dimitar/BqwAk/
if you need to keep a reference of the lis into a collection, use
.filterinstead:if all have .parent and only one can be active, you don’t really care so you can just do
or
… to double check if they don’t all have .parent.