L@_@K<html>
<head>
<title>Create Child Button</title>
</head>
<body>
<div id="mydiv">
<input id="btnRoot" type="button" value="Root" /><br />
</div>
</body>
<script type="text/javascript">var oContainer = document.getElementById("mydiv");
var oRoot = document.getElementById("btnRoot");
oRoot.onclick = CreateChild;function CreateChild()
{
var btnChild = document.createElement("input");
btnChild.type = "button";
btnChild.id = this.id + "_" + oContainer.getElementsByTagName("input").length;
btnChild.value = btnChild.id;
btnChild.onclick = CreateChild; oContainer.appendChild(btnChild);
oContainer.appendChild(document.createElement("br"));
}
</script>
</html>
<head>
<title>Create Child Button</title>
</head>
<body>
<div id="mydiv">
<input id="btnRoot" type="button" value="Root" /><br />
</div>
</body>
<script type="text/javascript">var oContainer = document.getElementById("mydiv");
var oRoot = document.getElementById("btnRoot");
oRoot.onclick = CreateChild;function CreateChild()
{
var btnChild = document.createElement("input");
btnChild.type = "button";
btnChild.id = this.id + "_" + oContainer.getElementsByTagName("input").length;
btnChild.value = btnChild.id;
btnChild.onclick = CreateChild; oContainer.appendChild(btnChild);
oContainer.appendChild(document.createElement("br"));
}
</script>
</html>
解决方案 »
- jquery里面带参数的方法是怎么实现的?
- js 控制treeview 的开关状态
- 请问如何根据输入的月份知道次月共有几周?
- Ext.form.TextField 浏览框监听事件无法执行,求高手解答
- javacript--history.go问题
- JavaScript 正则表达式 验证网址
- 关于Scripting.FileSystemObject,不支持网络拷贝麽?
- 怎么做到页面提交一次就在页面下方表格中增加一行?非常感谢
- 高分求救:在同一窗口中如何自动转到另一个网页,不用点击连接
- 能不能动态的定义上onClick事件
- 如何获取selection中的元素
- 如何得到已匹配表达式的字符串,例如...
我把事件写错了。
不能写createchild()
要写createchild。。
javascript里面函数也是一个对象。
谢谢兄弟。
把html码写在指定的地方。。
有没有什么办法????
<head>
<title>Create Child Button</title>
</head>
<body>
<div id="divRoot">
<input id="btnRoot" type="button" value="Root" style="cursor: hand;" /><br>
</div>
</body>
<script type="text/javascript">var oRoot = document.getElementById("btnRoot");
oRoot.container = null;
oRoot.onclick = CreateChild;function CreateChild()
{
//alert(this.nextSibling.nodeName);
if (this.container == null)
{
var divContainer = document.createElement("div");
this.container = this.parentNode.insertBefore(divContainer, this.nextSibling);
this.container.style.marginLeft = "20px";
this.container.style.border = "1px solid blue";
if (this.container.nextSibling)
{
this.parentNode.removeChild(this.container.nextSibling);
}
} var btnChild = document.createElement("input");
btnChild.type = "button";
btnChild.id = this.id + "_" + this.container.getElementsByTagName("input").length;
btnChild.value = btnChild.id;
btnChild.style.cursor = "hand";
btnChild.onclick = CreateChild; if (this.container.hasChildNodes())
{
this.container.appendChild(document.createElement("br"));
}
this.container.appendChild(btnChild);
}
</script>
</html>
hahahahaha
你要是在武汉
我就请你吃饭
把你QQ留下把???