I have the next output code:
<div class="post-term">
<a href="/term/1" class="color-cc0000">historical</a>
</div>
<div class="post-term">
<a href="/term/2" class="color-999999">historical</a>
</div>
How to take string after "color-" in class attribute and add css background-color inline style?
The resulting code should be:
<div class="post-term">
<a href="/term/1" style="background-color: #cc0000">historical</a>
</div>
<div class="post-term">
<a href="/term/2" style="background-color: #999999">historical</a>
</div>
I'm using Drupal Views so just can add css class attribute to target string with Javascript.
The problem with different codes I tried is that only changes correctly the first class and the next ones just drop the string. Let me explain better in the next resulting output code:
<div class="post-term">
<a href="/term/1" style="background-color: #cc0000">historical</a>
</div>
<div class="post-term">
<a href="/term/2" class="color-">historical</a>
</div>
Thanks a lot in advance.
data-attribute.