The method that works in both <script>
blocks and inline Javascript is \uxxxx
, where xxxx
is the hexadecimal character code.
<
–\u003c
>
–\u003e
"
–\u0022
'
–\u0027
\
–\u005c
&
–\u0026
HTML:
<div onClick="alert('Hello \u0022>')">click me</div>
<script>
var s="Hello \u003c/script\u003e";
</script>
solved tags inside of javascript code?