mheavers
mheavers

Reputation: 30158

Using CSS to select dom elements to select a class name containing a number greater than X

I was researching css attribute selectors to try and solve a problem of mine:

https://developer.mozilla.org/en-US/docs/CSS/Attribute_selectors

I have a bunch of dom elements which are all classed according to their depth in a json hierarchy (even though they are not nested in the DOM). So the dom might look like this:

<g class="node0">
<g class="node2">
<g class="node2">
<g class="node1">
<g class="node3">

I want to write a selector that targets g nodes with a class of node2 or higher. Is there a way to do this with pure css?

Upvotes: 2

Views: 113

Answers (1)

Talha Akbar
Talha Akbar

Reputation: 10030

[class^=node]:not(.node0):not(.node1) {
   // styles here
}

Fiddle

Upvotes: 3

Related Questions