将光标聚焦到隐藏的字段 [英] Focus cursor to a hidden field
本文介绍了将光标聚焦到隐藏的字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个脚本,我希望光标集中在隐藏的字段上,但似乎不起作用.当我使该字段可见时,它似乎起作用.
I have this script where i want cursor to be focused on hidden field but it doesn't seem to be working . When i make the field visible it seems to work.
$(document).ready(function(){
$("#card_number").focus();
$("#card_number").keypress(function() {
alert($("#card_number").val());
});
});
推荐答案
您不能专注于隐藏元素.
You can't focus on a hidden element.
您可以使用opacity: 0
代替display: none
,并且可以专注于元素.
You can use opacity: 0
instead of display: none
and you will be able to focus on the element.
这篇关于将光标聚焦到隐藏的字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文