jQuery-使用display:block选择所有锚标签 [英] Jquery - select all anchor tags with display:block
本文介绍了jQuery-使用display:block选择所有锚标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我无法理解该怎么做?
给出一个充满锚标签的页面,我只想选择CSS属性为display:block
的那些元素.
Given a page full of anchor tags, I only want to select those elements with the CSS property display:block
.
我认为我可以使用jQuery循环(警告伪代码!)
I think I can do it with a jQuery loop (warning pseudo code!)
var myarray;
$('a').each(function(arg1, arg2) {
if ($(arg2).css('display')=='block')
myarray.push(arg2);
}
但是没有简单的方法吗?
But isn't there a simpler way?
推荐答案
您可以将 filter
与以下功能一起使用参数.
You can use filter
with a function as the parameter.
$('a').filter(function (index) {
return $(this).css("display") === "block";
})
这篇关于jQuery-使用display:block选择所有锚标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文