javascript - How to get nth child value using jquery -
i have following html:
<div id="buildyourform"> <div class="fieldwrapper" id="field1"> <input type="text" placeholder="co-author name" class="fieldname m-wrap medium"> <input type="text" placeholder="co-author affiliation/organization" class="fieldtype m-wrap medium"> </div> <div class="fieldwrapper" id="field2"> <input type="text" placeholder="co-author name" class="fieldname m-wrap medium"> <input type="text" placeholder="co-author affiliation/organization" class="fieldtype m-wrap medium"> </div> </div>
i want value of input boxes each of div of buildyourform
<script> $('#buildyourform > div:nth-child(i) > input.fieldname').val() </script>
i tried above code it's not working please help.
you can use :eq()
following.
var first = $('.fieldname:eq(0)').val() var second = $('.fieldname:eq(1)').val()
Comments
Post a Comment