输入按钮作为标签 [英] Enter button works as tab
本文介绍了输入按钮作为标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我只是在页面上有按钮而没有其他的东西
< button> hello< / button>
当我打开页面并按下标签时,它会显示按钮,但我想以这种方式如果我输入它应该来到那个按钮。
这是我写的代码,但它不工作
<$ c $ ('keydown',function(e){
if(e.keyCode == 13)e()。$(document).ready(function(){
$('。EntTab')。 .keyCode = 9;
返回false;
});
});
需要帮助解决这个问题。
解决方案
检查此!
$(function(){$(document).keydown(function(e()){ ){if(e.keyCode == 13){$(button#hel)。focus();} else if(e.keyCode == 9){var e = jQuery.Event(keydown,{keyCode :9}); $(document).trigger(e);} return false;});});
< script src =https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js>< /脚本>< button id =hel> hello< / button><按钮> hello< /按钮><按钮> hello< / button>
I just have button in a page and nothing else
<button>hello</button>
When I open the page and press tab it comes to button but instead I want it in such a way that if I hit enter it should come to that button.
This is the code that I have written but it is not working
$(document).ready(function () {
$('.EntTab').on('keydown', function (e) {
if (e.keyCode == 13) e.keyCode = 9;
return false;
});
});
Need help in tackling this.
解决方案
Check this!
$(function() {
$(document).keydown(function(e) {
if (e.keyCode == 13) {
$("button#hel").focus();
} else if (e.keyCode == 9) {
var e = jQuery.Event("keydown", {
keyCode: 9
});
$(document).trigger(e);
}
return false;
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button id="hel">hello</button>
<button>hello</button>
<button>hello</button>
这篇关于输入按钮作为标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文