In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces the relevant knowledge of "how to clone or copy nodes in JavaScript". The editor shows you the operation process through an actual case. The operation method is simple, fast and practical. I hope this article "how to clone or copy nodes in JavaScript" can help you solve the problem.
Syntax:
NodeObject.cloneNode (boolean)
Parameter description:
Parameter description
NodeObject node object, that is, the node to be cloned
Boolean Boolean value, whether it is fully cloned.
True: full clone. To clone a node completely is to clone everything, including its child nodes, text nodes, whatever there is.
False: clone only the current node, not any child nodes, nor the text it wraps.
Of course, if the node to be cloned does not have any child nodes, the two are the same.
For example, clone the node of id= "demo":
?
# demo {
Width:250px
Padding:0px 10px 10px 10px
Border:1px solid # ccc
Background-color:#ededed
}
# demo div {
Height:50px
Width:250px
Margin-top:10px
Text-align:center
Line-height:50px
Background-color:#ccc
}
How to delete a node by Javascript removeChild ()
Syntax:
Parent.removeChild (thisNode)
Parameter description:
Parameter description
ThisNode current node, that is, the node to be deleted
The parent of the current node of parent, thisNode [XSS _ clean]
For example, the statement to delete the node of id= "demo" is:
?
one
two
Var thisNode=document.getElementById ("demo")
ThisNode [XSS _ clean] .removeNode (thisNode)
For example, delete a node:
Div id= "demo" >
Div id= "thisNode" > Click to delete me / div >
/ div >
Script type= "text/javascript" >
Document.getElementById ("thisNode") .onclick=function () {
This [XSS _ clean] .removeChild (this)
}
/ script >
Example demonstration:
# demo {
Width:250px
Padding:0px 10px 10px 10px
Border:1px solid # ccc
Background-color:#ededed
}
# demo div {
Height:50px
Width:250px
Margin-top:10px
Text-align:center
Line-height:50px
Background-color:#ccc
}
That's all for "how JavaScript Clones or replicates nodes". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.