-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
33 lines (27 loc) · 985 Bytes
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<video autoplay="autoplay" muted playsinline="playsinline" class="video">
<source src="/static-assets/video/cats_1.mp4" type="video/mp4">
</video>
<button id="simple-clone">Clone video without inserting</button>
<button id="clone-and-insert">Insert video (or clone and insert ) after original one</button>
<script>
var cloneBtn = document.getElementById('simple-clone');
var cloneAndInsertBtn = document.getElementById('clone-and-insert');
var elem = document.querySelector('video');
var clone;
var cloned = false;
var inserted = false;
cloneBtn.addEventListener('click', function (evt) {
evt.preventDefault();
if (cloned) { return false; }
clone = elem.cloneNode(true);
cloned = true;
});
cloneAndInsertBtn.addEventListener('click', function (evt) {
evt.preventDefault();
if (inserted) { return false; }
clone = clone ? clone : elem.cloneNode(true);
clone.classList.add('cloned');
elem.parentNode.appendChild(clone);
inserted = true;
});
</script>