Javascript – Find a character and the character before it in an element and wrap it with a span
I want to wrap an apostrophe that appears in h1 tags and character immediately before it. e.g. <h1>Can't</h1> would be like this <h1>Ca<span>n'</span>t</h1> I can do the apostrophe part using the following $("h1:contains('')").html(function(_, html) { return html.replace(/(')/g, '<span>$1</span>'); }); span…