changing span class changes ALL spans, how to make it specific??
I have pages with several <span> elements, each of which contains different text.
I want to change the button color depending on the span text per se.
All the spans are like this:
<span class="btn btn-XXXXXXX">text</span>
where I want to change btn-XXXXX depending on the value of text
Problem is if I use a statement like this:
if ($("span:contains('Check Out')")) {
$('.btn').addClass('btn-success').removeClass('btn-primary');
}
it will change ALL the spans on the page because the statement IS true.
How do I limit each class change to only the SPECIFIC span containing the text value and not have other spans' button classes change??
I have 3 or 4 spans per page to change and the changes must be span-specific according to the spans' text values, which will be different per page.
Thank you, Tom