I have multiple buttons on a page and I want to simulate a click on the NEXT button.
$('input, select').keydown(function(e){
if(e.which == 13)
//$('input[type*=button]').click();
$(this).next('input[type*=button]').click();
});
Html:
<tr>
<td class="cell">
<input type="text" name="domain" class="entryfield" value="http://">
</td>
</tr>
<tr>
<td class="cell" align="right" colspan="2">
<input type="button" class="button" value="Get IP" id="submitDomain"/>
</td>
</tr>
The commented code works, but that clicks all buttons on the page.
Any help is appreciated, thanks.
Given your markup:
Basically, find the
closesttable row, then find its immediate siblingtr. Inside thattrfindthe button you’d like to click.Next finds the immediately following sibling, so calling
nexton theinputthat the event occurred on wouldn’t actually find anything.Example: http://jsfiddle.net/N3WBP/