This question already has an answer here:
- Can't append <script> element 18 answers
I need to use childappend or jquery append() to append some tag stuff into the document. From what I can tell, this is getting stripped out. Anyone know how to do it?
DEMO
Or
This worked for me..
Note that the "/" of the inner
</script>
has been escaped to be"<\/script>"
. If it is not, it actually closes the outer<script>
tag.The script added wont be visible but will get executed. Hope that helps.
Try this:
Note that the script will load and you can access the variables inside it, but you wouldn't see the actual
<script>
tag in the DOM.If you need to append a script so that it's parsed you could do as google does for his +1 button
.text()
makes it possible to append script tags with it being rendered as HTML.OR