Using jQuery to echo text

Posted by susmits on Stack Overflow See other posts from Stack Overflow or by susmits
Published on 2010-04-01T17:16:39Z Indexed on 2010/04/01 17:23 UTC
Read the original article Hit count: 320

Filed under:
|

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!

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about JavaScript