I have a case when the HTML
is being generated dynamically using JS
.
I want to apply some styles for given code for specific class. The problem is I can't change HTML
syntax, because it is an external resource returned into my client app.
In case:
<div class="parent">
<div class="c1" />
<div class="c1" />
<div class="c1" />
<div class="c1" /> // this one should be selected
</div>
In other case:
<div class="parent">
<div class="c1" />
<div class="c1" />
<div class="c1" />
<div class="c1" /> // this one should be selected
<div class="c2" />
</div>
In other words, I want to select the last child within parent
block that contains chosen-css-class
.
I tried :last-of-type
, but it doesn't work for classes. Is it possible to solve this issue using CSS
only?
Also tried to find something on Web, but wasn't lucky too much...