I have a snippet of code kinda/sorta like this:
<script>
var foo = "<span>Hello <script>var bar = 1;</script> world</span>" ;
</script>
This barfs and displays and renders the span. The problem is caused by the " value in the variable.
I have worked around it by escaping the \ and changing it to
<script>
var foo = "<span>Hello <script>var bar = 1;<\/script> world</span>" ;
foo.replace("\/script", "/script") ;
</script>
This works fine. This seems really, really hokey. There has to be a better way to do this??