Reputation: 10982
I have a series of double and triple word combinations that require the use of a hyphen to function in a filter situation, but I don't want to hyphens to show on the web page. Therefore I would like to target them using jQuery and change their color to blend in with the background of the page.
I have words like Social-Media, Content-Management, etc., and they show up in a context like this:
<li><a class="filterName" href="#Content-Management">Content-Management</a></li>
I have been able to target the entire word with effect, but I have not been able to just target the hyphen.
I have tried the following:
$('a.filterName:("\-\")').css("color", "red");
What is the correct way to target the hyphen?
Upvotes: 0
Views: 30
Reputation: 207901
$('a:contains("-")').html(function () {
return $(this).text().replace('-', '<span class="hideme">-</span>')
})
Upvotes: 2