| |

VerySource

 Forgot password?
 Register
Search
View: 652|Reply: 2

I would like to ask cloneNode, how is previousSibling used.

[Copy link]

1

Threads

8

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

Post time: 2020-1-7 22:20:01
| Show all posts |Read mode
<!-Why the following code will not be copied one by one but all copied Solve->
<HTML>
 <HEAD>
  <TITLE> New Document </ TITLE>
<SCRIPT LANGUAGE = "JavaScript">
 <!-
function clone (obj) {
var newDiv = obj.cloneNode (true);
obj.insertBefore (newDiv);
}

 //->
 </ SCRIPT>

 </ HEAD>

 <BODY>

<FORM METHOD = POST ACTION = "">
<div style = "height: 20px" align = "center"> xxx <span> aaa <span> </ div>
<INPUT TYPE = "button" value = "clone" onclick = "clone (this.previousSibling)">
</ FORM>
 </ BODY>
</ HTML>
Reply

Use magic Report

0

Threads

5

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-1-9 11:27:02
| Show all posts
Node.cloneNode () duplicate a node and, optionally, all of its descendants
Ranch

Availability

DOM Level 1 Core
Synopsis
Node cloneNode (boolean deep);
Arguments
deep

If this argument is true, cloneNode () recursively clones all descendants of this node. Otherwise, it clones only this node.
Returns

A copy of this node.
Description

The cloneNode () method makes and returns a copy of the node on which it is called. If passed the argument true, it recursively clones all descendants of the node as well. Otherwise, it clones only the node and none of its children. The returned node is not part of the document tree, and its parentNode property is null. When an Element node is cloned, all of its attributes are also cloned. Note, however, that EventListener functions registered on a node are not clone
Reply

Use magic Report

1

Threads

8

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

 Author| Post time: 2020-1-10 21:36:01
| Show all posts
Just understand the general meaning. But no answer seems to be found. Continue to solve.
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list