views:

57

answers:

1

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.

+2  A: 
var $blueEles = $("*").filter(function() {
    return $(this).css("color") == 'blue';
});
$blueEles.each(function() {
    alert(this.id);
});
$blueEles.hide();
// etc
karim79