+ 1

How can I clone content from div A to div B. If I scroll in div A, div B will show the scrolling content in real-time.

The content in div B is 'static', even if I scroll in div A: <!-- my HTML code --> <div class="A"> <img src="picture"> <img src="picture"> </div> <div class="B"> everything that happens in div A </div> <!-- my JavaScript code --> <script> var elmnt = document.getElementsByClassName("A")[0]; var cln = elmnt.cloneNode(true); document.body.appendChild(cln); </script>

30th Sep 2017, 2:01 PM
GiggZ Westworld
GiggZ Westworld - avatar
1 Réponse
+ 3
You can do this by using event handler! Use the onscroll attr in the div <div class="A" onscroll="yourJsFunction()"> i wrote you a quick example: https://code.sololearn.com/W9A9iwWG2g26/#html
30th Sep 2017, 3:09 PM
Chrizzhigh
Chrizzhigh - avatar