如何删除嵌套的html元素 - Web 开发 / JavaScript
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<script type="text/javascript">
function $(nodeId)
{
return document.getElementById(nodeId);
}
function removeMsg()
{
var nodeBtn = $("remove");//按钮
document.body.removeChild(nodeBtn);
}
</script>
</head>
<body>
<div id="div1">
<div id="div2">
<input type="button" id="remove" value="删除它" onclick="removeMsg();" />
</div>
</div>
</body>
</html>
如果没有div1和div2,按钮可以很顺利地删除,要是有的话,该怎么办???(用jquery实现也行)
HTML code:
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<script type="text/javascript">
function $(nodeId)
{
return document.getElementById(nodeId);
}
function removeMsg()
{
var nodeBtn = $("remove");//按钮
nodeBtn.parentNode.removeChild(nodeBtn);
}
</script>
</head>
<body>
<div id="div1">
<div id="div2">
<input type="button&q
相关问答:
form表单下拉框的蓝色怎么去掉呢,我想把下拉框的颜色设为透明的
may be no way.
像QQ空间里的那些透明的下拉框是怎么弄得呢?
引用
像QQ空间里的那些透明的下拉框是怎么弄得呢?
用层模拟的吧
基本都 ......
如何对xml内容数据进行比较
例如:
<?xml version='1.0' encoding='utf-8'?>
<TestLIST>
<PID>40</PID>
<TestName>深圳市</TestName>
......
我用object标签载入一个外部的html文件可是用vs2008打开却不显示,显示红叉,请问是怎么回事?
用iframe载入。
可以用iframe载入
用iframe载入超链接地址不改变,没办法跳转页面
引用
用iframe载入超链接地址 ......
<span id="Label1">如果能看到这个标签 说明我们已经能从HTML 页面上获取了这个元素控件传递到Silverlight应用程序中 </span>
<br />
<input type="sub ......
在发表评论时 过滤 如何:<br/> <hr/> 双引号 单引号 还有其他 等 有好的方法告诉一下 谢谢
.replace(/<\w+[^>]*>/g,"").replace(/'/g,"''")
将单引号换成2个 ......