Reputation: 3567
I'm new to Mootools and I'm stuck on the following problem.
I have this ul
based menu.
<ul class="moo_mmenu">
<li>
<a href="#">
<span>Trang Chu</span>
</a>
<ul>
<li>
<a href="#">
<span>lv2</span>
</a>
</li>
<li>
<a href="#">
<span>lv2</span>
</a>
</li>
</ul>
</li>
</ul>
And I'm using this mootools javascript code:
window.addEvent('domready', function() {
var root = $$('.moo_mmenu');
var units = // !!! << here is my problem, see below :(
units.setStyle('background-color' , 'blue');
});
in the units
variable I want to select all the li
elements in the class moo_mmenu
by using root varible, like
// jQuery
$('li', root);
Please help, thank you.
Upvotes: 2
Views: 226
Reputation: 30258
If you use id="moo_mmenu"
var units = $$('#moo_mmenu li');
Will work fine.
If you really want to use class="moo_mmenu"
(and I really don't think you do.) you can do this...
var units = $$('.moo_mmenu li');
If you need to get the li
elements directly from the root
var you can do.
root.getElements('li');
Upvotes: 2