First you need to define the variables. There are three variable that are required to do this.
- Locate the element you want to move. In this instance we want to move the side bar.
- Locate the Parent element. This is the “Div” (or tag) that surround the Child element you want to add the new element above.
- Finally, locate the child element that you want to add above.
var sideBar = document.querySelector("#sidebar"); var tarP = document.querySelector("#main").getElementsByTagName('div'); var tar = document.getElementsByClassName('woocommerce-tabs wc-tabs-wrapper');
Locating all the elements is that hardest part and so if your script is not working then this is why.
Finally, the function where the magic happens.