jQuery toggleClass example
Toggle class name on click in jQuery
by cchana
HTML
<a href="/">Pro Aluminium</a>
<a href="/">Sadio Mane</a>
<a href="/">Mo</a>
CSS
a {
color: red;
}
a.bobby,
a.pro-aluminium{
color:green
}
a.sadio-mane {
color: blue;
}
JavaScript
$('a').each(function() {
var item = $(this);
item.addClass(item.text().toLowerCase().replace(/\u00a0/g, '-'));
})