Java教程

javascript当中removeChild的用法

本文主要是介绍javascript当中removeChild的用法,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

例 1.5(removeChild()IEFF.html)


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>

</HEAD>

<BODY>

<div id="contain">
    <div id="a">a </div>
    <div id="b">b </div>
    <div id="c">c </div>
</div>

<script>
/*马克-to-win: DIV object: Inherits from Element object,
 Element object Inherits from Node object
 b 是个 DIV object.
    */
var b = document.getElementById("b");
var c = b.parentNode;
/*Node.removeChild() (Method)
A method for removing child nodes from the collection.

Property/method value type: Node object
JavaScript syntax: - myNode.removeChild(aNode)
Argument list: aNode The node object to be removed
*/
var cs=document.getElementById("contain");
alert("c===cs is "+(c===cs));
c.removeChild(b);
</script>
</BODY>
</HTML>


更多内容请见原文,文章转载自:https://blog.csdn.net/qq_44594371/article/details/103063700

这篇关于javascript当中removeChild的用法的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!