Mubeen Hussain Mubeen Hussain - 29 days ago 5
jQuery Question

Making text bold in jQuery

I'm currently having a problem replacing the current text with the same text but in bold. I've tried the following

var valueInRow = $(value).closest(".label.imaged").text();
var result = valueInRow.bold();
$(value).closest(".label.imaged").text().replaceWith(result);


But I'm not sure why it doesn't work; Any ideas?

Answer

You can clearly use .wrapInner():

Wrap an HTML structure around the content of each element in the set of matched elements.

$(value).closest(".label.imaged").wrapInner("<strong />");