开发者

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>


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());
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜