This article mainly introduces how to use javascript to replace existing elements with replaceChild (). For more information, see replaceChild (a, B ).
Parameter a: the node to be inserted,
Parameter B: the node to be replaced
The Code is as
ReplaceChild (a, B) is used to replace existing elements in the document.Parameter a: the node to be inserted,Parameter B: the node to be replacedCopy codeThe Code is as follows:Var oDiv = document. getElementById ("guoDiv ");Var oSpan = document.
DOM node replacement or modification function replaceChild () usage instance, domreplacechild
This example describes how to replace or modify the replaceChild () function of a DOM node. Share it with you for your reference. The specific analysis is
The example in this article describes the substitution or modification function replacechild () Usage of a DOM node. Share to everyone for your reference. The specific analysis is as follows:
The replacement process for DOM nodes:(1) Create a new
This article mainly introduces the use of JavaScript replacement elements ReplaceChild (), need friends can refer to the followingReplaceChild (A,B) is a parameter that replaces an existing element in a document A: the node to be inserted, parameter
ReplaceChild (A,B) is used to replace an existing element in a document.
Parameter A: the node to insert,
Parameter B: the node to replace
Copy Code code as follows:
var odiv = document.getElementById ("Guodiv");
var Ospan =
Introduction to JavaScriptJavaScript is a client-side scripting language that is Object-and event-driven and has relative security, is a dynamic, weakly-typed, prototype-based language with built-in support classes. Its interpreter is called the
I. Element Node // test element node, output node name, node type, and node value varliElementsdocument. getElementsByTagName (& quot; li & quot;); for (vari0; I & lt; liElements. length; I ++) {alert (liElements [I]. nodeName);
I. Element nodes
//
JavaScript automatically generates webpage elements (buttons, text, etc.). javascript automatically generates
Method for creating elements:
1. Use createTextNode () to create a Text object
2. Create a tag object using createElement ()
3.
Unified interface: Add IE methods and attributes to FireFox. How does one run the code (pure js version) in Z-Blog? Because FF does not support insertAdjacentElement, the "Running code" link cannot be displayed. Today, I Googled and found a good
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.