2013-10-10 112 views

回答

3
$('#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 
} 
+1

你不需要'> 0';) – Archer

+0

笑这就是正确的..但离开它那办法 。 :) –

+0

这只是一个额外的逻辑步骤,不是必需的。它以任何方式产生相同的结果。 – Archer