0

Can anyone share how I could wrap every asterix on a page within an enclosing div.

So that:

Tasty drinks *

Becomes:

Tasty drinks <span class="disclaimer">*</span>

I've tried a few online examples and can get it to work on almost any character except an asterix.

KyleMit
  • 30,350
  • 66
  • 462
  • 664
Peter
  • 89
  • 1
  • 9

1 Answers1

6

If you are using jQuery, you could use

$("body").children().each(function() {
    $(this).html($(this).html().replace(/\*/g,"<span class='disclaimer'>*</span>"));
});

Here's a fiddle (Adapted from this question)

Community
  • 1
  • 1
Brandon Horst
  • 1,921
  • 16
  • 26