$('.change').click(function() {
$('.link').each(function(e) {
var color = this.className.match(/color-\w+/gi);
alert(color);
});
});
I’d basically like this to alert the regular expression found with \w+ rather than the entire string. How can I do this?
Additionally, how can I remove color- without removing the regular expression after this instance?
You can use the javascript regular expressions to loop though the matches which will return the groups in an array. You can also use the
replacefunction with a group back reference to remove the color-http://jsfiddle.net/cYmxB/2/