When I click on the button I want to grab the text in the nearest text box using Jquery. Usually closest did the trick, but this time I got the nearest TR and searched within it using ‘find’.
FORM CODE
1 2 3 4 |
echo '<tr><td><input class="mykeyword" type="text" value="fgfggfg"></td> <td><a class="btn btn-info" id="savekeyword">SAVE</a> </td></tr>'; |
The answer: –
1 2 3 4 |
var thetext = $(this).closest("tr").find(".mykeyword").val(); alert(thetext); |