I have table like this-
<table class='table'>
<tr>
<td class="td"><input type="text" name="name<%=f.getId()%>" value="<%=f.getName()%>"/>
</td>
<td class="td"><input type="text" id="field_length" size="3" name="length<%=f.getId()%>" value="<%=f.getLength()%>"/></td>
<td class="td"><input type="text" name="tooltip<%=f.getId()%>" value="<%=f.getToolTip()%>"/></td>
</tr>
<tr>
same like the previous.......
</tr>
<tr>
same like previous....
</tr>
Now I want to change the value in the text box located in the second row with the id “field_length”. I tried to use jquery to do that.
$(‘tr:nth-child(2) input:text#field_length’).val(10);
But this is not working. Can any body please provide me a little help regarding this.
Use this instead, just select the input with name starting with length instead of the faulty ID construction. The first part of the element names are fixed … you can remove the IDs if you want with this solution.
Fiddle sample