JAVASCRIPT動態加載js文件

核心方法:createElement

通過createElement動態創建一個元素,並修改它的屬性,最終把它加入到documet.body的子節點裡。

index.html代碼:

var/>
/>
document.body.appendChild(script);

a.js代碼:

function test(){

alert("hello,world");

}

test();

運行結果肯定是hello,world啦!

本文由ISMY博客發佈


分享到:


相關文章: