核心方法:createElement
通過createElement動態創建一個元素,並修改它的屬性,最終把它加入到documet.body的子節點裡。
index.html代碼:
var/>
/>
document.body.appendChild(script);
a.js代碼:
function test(){
alert("hello,world");
}
test();
運行結果肯定是hello,world啦!
本文由ISMY博客發佈
閱讀更多 最後一個NPE 的文章
關鍵字: 編程語言 JavaScript 技術