我试图将焦点放在隐藏的文本框上.我希望当包含文本框的主体或div加载焦点时,应该在特定文本框上,以便键盘或任何其他设备的任何输入都被此元素捕获.我试过以下代码没有效果:
<body>
<input type="text" id="exp" maxlength="16"></input>
<input type="text" id="exp2" maxlength="16"></input>
<script>
$("#exp").hide();
$("#exp").focus();
$("#exp2").keypress(function(){
alert($("#exp").val());
});
</script>
</body>
Run Code Online (Sandbox Code Playgroud)
提出任何建议.jquery解决方案将是首选.
jquery ×1