Change parent | Sololearn: Learn to code for FREE!

+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?

11/12/2019 7:40:27 PM

Maryam

1 Answer

New Answer

+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.