2013-10-10 42 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