我想知道这是否可能。申请:首先对多个选择器
我有一个网页,我想专注于窗体中第一个启用可见的字段。第一个字段可以是输入字段或选择字段。我曾尝试(使用jQuery)以下格式
input,select:visible:enabled:first
也
(input,select):visible:enabled:first
但是这些都似乎为我工作。
所以这可以做到吗?
在此先感谢。
我想知道这是否可能。申请:首先对多个选择器
我有一个网页,我想专注于窗体中第一个启用可见的字段。第一个字段可以是输入字段或选择字段。我曾尝试(使用jQuery)以下格式
input,select:visible:enabled:first
也
(input,select):visible:enabled:first
但是这些都似乎为我工作。
所以这可以做到吗?
在此先感谢。
$('input,select').filter(':visible:enabled:first')
听起来像它会做你想做的。
这是未经测试,我有点担心的是怎么:first
的行为上有上涨,因此,如果不工作,你总是可以做:
$('input,select').filter(':visible:enabled').first();
尝试使用filter
选择:
$("input,select").filter(":visible:enabled:first");
重复的问题答案在这里给您的问题:jQuery的,将焦点设置在第一个启用输入或选择或在页面上的textarea](http://stackoverflow.com/questions/4328381/jquery-set -focus-on-the-first-enabled-input-or-select-or-textarea-on-the-page) – Franky
你是正确的Franky。当我搜索时,我设法错过了这种精神。抱歉。最适合我的解决方案是:input:visible:enabled:first。我错过了领先的':'输入。 – mazzaC
@BoltClock:我的声望不能让我标记为重复! – Franky