Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
17
rated 0 times [  19] [ 2]  / answers: 1 / hits: 86339  / 15 Years ago, mon, august 3, 2009, 12:00:00

How can I select all elements that have a specific CSS property applied, using jQuery? For example:



.Title
{
color:red;
rounded:true;
}

.Caption
{
color:black;
rounded:true;
}


How to select by property named rounded?



CSS class name is very flexible.



$(.Title).corner();
$(.Caption).corner();


How to replace this two operation to one operation. Maybe something like this:



$(.*->rounded).corner();


Is there any better way to do this?


More From » jquery

 Answers
63

You cannot (using a CSS selector) select elements based on the CSS properties that have been applied to them.



If you want to do this manually, you could select every element in the document, loop over them, and check the computed value of the property you are interested in (this would probably only work with real CSS properties though, not made up ones such as rounded). It would also would be slow.



Update in response to edits — group selectors:



$(.Title, .Caption).corner();

[#99013] Wednesday, July 29, 2009, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kalli

Total Points: 589
Total Questions: 105
Total Answers: 97

Location: Rwanda
Member since Thu, Feb 10, 2022
2 Years ago
kalli questions
Mon, Aug 23, 21, 00:00, 3 Years ago
Thu, Dec 3, 20, 00:00, 4 Years ago
Tue, Sep 22, 20, 00:00, 4 Years ago
;