Is it possible to use jQuery to echo text in place of a script tag? More precisely, is there a way to accomplish
<script type="text/javascript">
document.write("foo");
</script>
... without the use of document.write
? I am not happy about using document.write
after reading this.
I am aware that I could alternatively do this:
<span id="container"></span>
<script type="text/javascript">
$("#container").text("foo");
</script>
However, I'm interested to see if there's a way to do it without using a container element, preferably using jQuery.
Thanks in advance!
If you come up with a jQuery way of doing document.write()
, it'll be bad for all the same reasons.
You are better off just using document.write()
if that's what you need, or better yet, manipulating an existing element or appending a new element somewhere in the DOM--that's what jQuery is good at.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With