Pablo
Pablo

Reputation: 4313

output with javascript/jquery

I have a script that runs within the body. How can I make it output directly after itself. Similar to echo in php.

e.g.

    <div id="text">Text</div>

    <div id="someotherdiv">
    The text above says 
    <script>
    $('#text').html().echo?;
    </script>
    </div>

Upvotes: 0

Views: 88

Answers (1)

SLaks
SLaks

Reputation: 887509

You're looking for document.write, like this:

document.write($('#text').html());

EDIT: document.write will only work while the page is loading (as opposed to in an event handler or timer).
To append content later, use jQuery:

$('#someotherdiv').append($('#text').html());

Upvotes: 7

Related Questions