I need the name of the next button from the input feald, the button can be in different positions(in table, in div after table, etc.). Like a find next in quelltext.
HTML:
<table>
<tr>
<td>Benutzer:</td>
<td><input type=text id=Benutzername name=Benutzername/></td>
</tr>
<tr>
<td>Passwort:</td>
<td><input type=password id=Passwort name=Passwort/></td>
</tr>
<tr>
<td></td>
<td class=fr><a href=#info class=submit onclick=login()>
<button>Login</button>
</a></td>
</tr>
</table>
JS:
$('input').keypress(function(event){
if(event.which==13){
event.preventDefault();
alert($(this).closest('button').html());
alert($(this).next('button').html());
}
});
The alert is always undefined.
EDIT:
Sure i can give the button a unique id but i have 1 page with 10 buttons and each 10-20 inputs. So i hope a easy way to call always the next and dont give alle buttons a uniqe id and a seperate funktion to all inputs.
EDIT2:
I meen with the name the innerHTML of the button.
EDIT3:
The table is not always around the inputs.
EDIT4:
Better example http://jsfiddle.net/LF6pK/7/ and i prefer a dynamic like next button solution.