var area = document.getElementById("newArea");
var newNode = document.createElement("input");
newNode.type = "button";
newNode.value = "这是测试加载的小例子";
//newNode.setAttribute("type", "button");
//newNode.setAttribute("value", "这是测试加载的小例子");
newNode.onclick = function test(){
alert("click");
}
var o = area.appendChild(newNode);
详细解决方案
appendChild()跟insertBefore
热度:512 发布时间:2012-10-26 10:30:59.0
相关解决方案
- 行15: 没法获取属性“appendChild”的值: 对象为 null 或未定义
- C# 中的 webbrowser.Document.Body.appendChild 没真正写入到源网页中
- C# 中的 webbrowser.Document.Body.appendChild 没真正写入到源网页中
- document.appendChild(form)与document.body.appendChild(form)的差别
- appendChild()跟insertBefore
- 错误:无法在“节点”上执行“ appendChild”:在JavaScript中使用微调器时参数1不是“节点”类型
- 为什么IE10说`对象不支持属性或方法'appendchild'
- insertBefore
- DOMException: Failed to execute ‘insertBefore‘ on ‘Note‘解决方法