Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试查找未知数量元素中的任何元素是否具有焦点
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 }