I'm testing a function to select the part of a title that comes after the colon:
$('.carousel .item .carousel-caption h2').each(function(){
var val = $(this).text();
console.log(val);
var string = val.substr(val.indexOf(":") + 1);
console.log(string);
var foo = val.replace('/('+string+')/g', '<span>$1</span>');
console.log(foo);
});
I can select the part I need, but I can not include the tags. In the console, the variable foo appears equal to variable val.