Joe
Joe

Reputation: 415

Select and change property of all elements with css("color") of a certain value

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

Answers (1)

karim79
karim79

Reputation: 342635

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

Upvotes: 2

Related Questions