jquery select all br with display:none;
How do I select an element based on its css?
开发者_如何学运维I need to select a br with inline style display:none. This is not the same thing as br:hidden, because that selects elements that are hidden in other ways, and I don't want that.
Thanks.
You could try:
$("br").filter(function() { return $(this).css("display") == "none" })
Another way to do this would be to use jQuery's attribute selector:
$("br[style$='display: none;']")
Using filter.
$("br").filter(function () {
return $(this).css("display") == "none";
});
How about something like this:
$(document).ready(function() {
$("div:hidden").each(function() {
if ($(this).css("display") == "none") {
// do something
}
});
});
Use jQuery.map:
var brs = $('br');
jQuery.map(brs, function(elem, i){
if(elem.css('display') == 'none')
return elem;
return null;
});
$("br").filter(function() {
return $(this).css("display") == "none";
})
Works like a charm.
精彩评论