小编Ale*_*tic的帖子

为什么cloneNode <script>标签不执行?

克隆的<script>标记不会执行.为什么?

例:

<script id="hello">
  console.log("hello execution count ", window.helloCount++);
</script>

<script id="action">
  document.body.appendChild(
    document.getElementById('hello').cloneNode(true));
  console.log('cloned the script');
</script>
Run Code Online (Sandbox Code Playgroud)

执行后,文档中有两个hello脚本,但只执行了一个.

http://jsbin.com/zuxoro/1/edit?html,console,output

这是我正在研究的一个更大问题的一部分,所以我知道这是一件愚蠢的事情.

javascript dom

9
推荐指数
2
解决办法
1215
查看次数

标签 统计

dom ×1

javascript ×1