Reputation: 415
How can I find all elements on a page which have a color of "blue"?
alert($("* [color=blue]").attr("id"));
The above example does not work. Please recognize that color is a CSS attribute. I'm certain it is possible I just cannot figure out the correct method to do so.
Upvotes: 2
Views: 1157
Reputation: 342635
var $blueEles = $("*").filter(function() {
return $(this).css("color") == 'blue';
});
$blueEles.each(function() {
alert(this.id);
});
$blueEles.hide();
// etc
Upvotes: 2