发布者:admin 发布时间:2019-10-01 阅读:
全部展开
所谓动态写法是指源文件中没有内容或需要修改的代码。此处显示的文本或内容必须使用JavaScript代码实现。
动态书写是一种非常常见的方法。
1.在innerHTML中输入html代码。除法= abc / divscriptdocument。
getElementById(abc)。
innerHTML =要编写的文本或内容/ script2,appendChild()方法:ulid = myListliCoffee / liliTea / li / ulbuttononclick = myFunction()单击以添加元素/ buttonscriptfunctionmyFunction(){varnode =文档到列表中。
createElement(LI); vartextnode =文档。
createTextNode(水);节点
appendChild(文本节点);文档。
getElementById(myList)。
appendChild(节点);}/脚本