javascript - jQuery .each deep selecting -


i traversing complex dom, have repetitive html structure

i using each feature in jquery

$('.row').each(function (index, object) {    $(object).find('label[for="duedate"] > .input-group > input:first').text(); }  

i trying use above code start traversal getting undefined in results.

a sample of html follows

<div class="row">      <div class="form-group ml-sm mr-sm">          <label class="control-label" for="duedate">due date</label>          <div class="input-group">              <span class="input-group-addon">                  <i class="fa fa-calendar"></i>              </span>              <input "type="text" data-plugin-datepicker class="form-control" readonly="readonly" required>              </div>          </div>      </div>  </div>  

i wanted traverse through each line of html looking specific classes , elements until hit input element , retrieve text.

can suggest correct way achieve this?

thanks

i think want:

$('.object-container  label[for="duedate"]').parent(".form-group").find("input:text").each(function() {     var text = $(this).val();     // text }); 

.form-group parent of label, selector had child. , input:text not child of label, it's descendant of .form-group.

and input in text field, use .val(). .text() text content of html node.


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -