LoginSignup
0

More than 5 years have passed since last update.

ノードを複製する。

Posted at

appendChildすると、元いた場所からノードが消えてしまう・・複製をしたい・・。

使用するメソッド

cloneNode

使い方

var hoge = document.querySelector('#hoge');
var clone = hoge.cloneNode(true); //引数に「ture」を指定

var wrap = document.querySelector('#wrap');
wrap.appendChild(clone);

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0