可以<body>
<div id=divId>ok</div>
<input onclick="document.all.divId.parentNode.removeChild(document.all.divId)" value=delete type=button>
</body>
<div id=divId>ok</div>
<input onclick="document.all.divId.parentNode.removeChild(document.all.divId)" value=delete type=button>
</body>
我的reference太差了。
有没有官方一点的javascript API啊?
true ChildNodes collection of the object is removed.
Return ValueReturns a reference to the object that is removed.ResThis property is accessible at run time. If elements are removed at run time, before the closing tag is parsed, areas of the document might not render.ExampleThis example uses the removeNode method to remove a table from the document hierarchy.<SCRIPT>
function fnRemove(){
// 'true' possible value specifies removal of childNodes also
oTable.removeNode(true);
}
</SCRIPT><TABLE ID = oTable>
<TR>
<TD>Cell 1</TD>
<TD>Cell 2</TD>
</TR>
</TABLE><INPUT TYPE = button VALUE = "Remove Table" onclick = "fnRemove()">
<SCRIPT>
function removeElement()
{
try
{
//The first child of the div is the bold element.
var oChild=Div1.children(0);
Div1.removeChild(oChild);
}
catch(x)
{
alert("You have already removed the bold element.
Page will be refreshed when you click OK.")
document.location.reload();
}
}
</SCRIPT>
</HEAD>
<BODY>
<DIV ID=Div1 onclick="removeElement()">
Click anywhere in this sentence to remove this <B>Bold</B> word.
</DIV>
</BODY>
<div id=divId>ok</div>
<input onclick="document.getElementById('divId').parentNode.removeChild(document.getElementById('divId'))" value=delete type=button>
</body>parentNode、removeChild均为w3c dom内容,所以没有必要再使用ie的all,这样只能在ie5+中使用了,而使用getElementById可以在所有支持w3c dom的浏览器中使用csdn ftp上的冬瓜上传的javascript宝典第四版,推荐……
啊,那我怎么可以找到它呢?