Detecting "enter" keyup event on checkbox
I've got a checkbox called 'beveiligdj'. It looks like this:
<label><input type="checkbox" id="beveiligdj" name="beveiligdj" value="j">Ja</label>
When you select it (by开发者_如何学编程 keyboard) and then press enter, it should go to the #beveiligdn
input (also a checkbox) But it does not!
$('#beveiligdj').keyup(function(event) {
if(event.keyCode == 13) {
checked = $('#beveiligdj').is(':checked');
if(checked) {
$('#beveiligdn').focus();
}
}
});
It just goes to the following field. How can I fix that?
You can try to use the old trick with the setting of the focus inside of setTimeout
:
setTimeout(function(){
$('#beveiligdn').focus();
},100);
You can even try to use 0 instead if 100.
精彩评论