I am using jquery version 1.3
<div id='mainPanel'>
<div>
<h3>Head #1 <a href="#"><input type="text" value="Type 1"/> </a></h3>
<div>
<div id="panel_1">
<div class="items">
<div><input type='text' value="0"/></div>
<div><input type='text' value="1"/></div>
<div><input type='text' value="2"/></div>
<div><input type='text' value="3"/></div>
</div>
</div>
</div>
<div>
<h3>Head #2 <a href="#"><input type="text" value="Type 2"/> </a></h3>
<div>
<div id="panel_2">
<div class="items">
<div><input type='text' value="0"/></div>
<div><input type='text' value="1"/></div>
<div><input type='text' value="2"/></div>
<div><input type='text' value="3"/></div>
</div>
</div>
</div>
<div>
</div>
Now, here I want to access the text field values from the chapter div and I need the identifier ie panel_1 and panel_2
so for this I wrote the following code
$("#mainPanel > div > h3").each(function(index) {
var panelId = $(this).attr('id');
var ele = $(this).next('div > div > div > div').each(function(index){
alert($(this).children('input').val());
});
});
Here I was not able to get the result using parent> child notation
HOW CAN I ACCESS H3> A> INPUT value here
source
share