+ 1

Change parent

Can I change the parent of an element in java script? For example I have div1 in div2 and I want to move div1 to div3. Can I?

12th Nov 2019, 7:40 PM
Maryam
1 Odpowiedź
+ 1
Sure: https://code.sololearn.com/WfPvQESWtXv1/?ref=app If you look at the HTML page, div2 is a child of div1. The JS changes this and alerts the parent of div2's id which it says is now div3.
12th Nov 2019, 8:46 PM
Russ
Russ - avatar