0

I think my problem is simple to resolve but i didn't find anything related to this. I just want to add a class id when i use JQuery replace.

Here i'm using this small script :

<script>
  $("body").html($("body").html().replace(" <strong>Mario</strong> game" , " <span class="class-id"><strong> Mario</strong> bros."));
  </script>

Can you help me? Thanks

Bob
  • 3
  • 2
  • 1
    You can't nest `"` inside `"` so just switch to `'`: `" ..."` . See the existing questions for more details. – freedomn-m Jul 02 '22 at 08:45

1 Answers1

0

what about

  $("body").replaceWith("<span class='red'><strong> Mario</strong> bros.");

Example here: https://codepen.io/polinq/pen/yLKNggV?editors=1111

pau
  • 88
  • 6