0
我试图找到,如果在元素的未知量的任何元素具有焦点检查中元素的数组元素具有焦点
if($('#wrapper ul li a:focus')) # there are multiple a tags that are dynamically generated
任何人都知道它是如何做?
我试图找到,如果在元素的未知量的任何元素具有焦点检查中元素的数组元素具有焦点
if($('#wrapper ul li a:focus')) # there are multiple a tags that are dynamically generated
任何人都知道它是如何做?
$('#wrapper ul li a:focus').length // get the number of items that has focus
$('#wrapper ul li a:focus').eq(0) //get's the first matched element
所以如果你需要检查,如果集合中元素的任何元素具有焦点
if($('#wrapper ul li a:focus').length){
// do something
}
你不需要'> 0';) – Archer
笑这就是正确的..但离开它那办法 。 :) –
这只是一个额外的逻辑步骤,不是必需的。它以任何方式产生相同的结果。 – Archer