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

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -