我有一个在体内运行的脚本.如何直接输出后自己输出.类似于php中的echo.
例如
<div id="text">Text</div>
<div id="someotherdiv">
The text above says
<script>
$('#text').html().echo?;
</script>
</div>
Run Code Online (Sandbox Code Playgroud)
你正在寻找document.write,像这样:
document.write($('#text').html());
Run Code Online (Sandbox Code Playgroud)
编辑:document.write仅在页面加载时工作(而不是在事件处理程序或计时器中).
要在以后添加内容,请使用jQuery:
$('#someotherdiv').append($('#text').html());
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
79 次 |
| 最近记录: |