2
I’m testing a function to select the part of a title that comes after the two-point sign:
$('.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’t include the tags. In the console, the foo variable appears equal to the val variable.
Marcelo, I’m glad you were able to solve and put the final code here. However it would be correct to mark as accepted the answer that led him to solve the problem.
– Sergio