views:

42

answers:

3

Hi ,

I am using jquery 1.3 version

<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 box values from head div and need a id i.e. panel_1 and panel_2

so to do that i have written down following code

  $("#mainPanel > div > h3").each(function(index) {

        var panelId = $(this).attr('id'); // i.e. panel_1 and all

        // parent > child notation
        var ele = $(this).next('div > div > div > div').each(function(index){ 


           alert($(this).children('input').val());


});

});

Here i am failed to get the result using parent > child notation

HOW CAN I ACCESS H3 > A > INPUT 's value here

+3  A: 
Pointy
but the problem is #panel_1 could be different as this blocks gradually increase , thats why i am crawling down to the elements
Hunt
A: 

i have replace

$(this).next('div > div > div > div').each(function(index) 

with following

$(this).next('div').find('div > div > div >input').each(function(index) 
Hunt
A: 

So you are given an id and need to find the inputs contained within its panel?

 $('#panel_' + givenId + ' input').each(function() { ...

or do you need to cycle through all of the panels and get the inputs?

Joey C.