Target a button with its content

I’ve seven buttons with same class but different content

<a class="button ordrViewBtn">Sold Out</a>
<a class="button ordrViewBtn">Re-Sell</a>
<a class="button ordrViewBtn">Sold Out</a>
<a class="button ordrViewBtn">Re-Sell</a>
<a class="button ordrViewBtn">Sold Out</a>
<a class="button ordrViewBtn">Re-Sell</a>
<a class="button ordrViewBtn">Sold Out</a>

I would like to change background color of all Sold Out button. is it possible to target a button with its content?

There is no way to target an element based on the element’s content. You’ll have to add javascript to do that.

Or can you add an additional class which has the appropriate background color? Might be easier…

<a class="button ordrViewBtn soldOut">Sold Out</a>
<a class="button ordrViewBtn">Re-Sell</a>
<a class="button ordrViewBtn soldOut">Sold Out</a>
<a class="button ordrViewBtn">Re-Sell</a>
<a class="button ordrViewBtn soldOut">Sold Out</a>
<a class="button ordrViewBtn">Re-Sell</a>
<a class="button ordrViewBtn soldOut">Sold Out</a>

.soldOut { background-color: red; }

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.