Getting text within h3 tag using Mootools Element properties
I have the following mootools code, please note that I need to get a cetain value in mootools and have no good mootools knowledge
I have the following html code
<div class="moduletable_menu">
<div class="tog">
<h3>Main Menu</h3>
</div>
<div class="cont">
<ul class="menu">.....</ul>
</div>
</div>
<div class="moduletable_menu">
<div class="tog">
<h3>Newsletter</h3>
</div>
<div class="cont">
//Newsletter form
</div>
</div>
I have the following m开发者_开发百科ootools code
var modules = $$('.cont');
var toggles = $$('.tog');
modules.each( function(mod, index){
//I need to get the innerHTML for h3 in here
});
This loops through all div tags that contain the class "cont", I however need to obtain the inner HTML for the h3 tag within div tag with class "tog", by looping through the div tags with the cont class?
Any help will be highly appreciated
getPrevious
will help you get the toggle div given a module div, and getElement
will get the h3 element within it.
See an example.
modules.each(function(module) {
var toggle = module.getPrevious('div.tog');
var headingText = toggle.getElement('h3').get('text');
});
精彩评论