jQuery before() and insertBefore() example

by Prajeesh_PR

HTML

<div class="box"><span class="ww">Ip man</span></div>

<div class="box1"><span class="ww2">Ip man 2</span></div>

CSS

.box {
  padding: 8px;
  background: grey;
  margin-bottom: 8px;
  width: 300px;
  height: 100px;
}

.box1 {
  padding: 8px;
  background: red;
  margin-bottom: 8px;
  width: 200px;
  height: 50px;
}

JavaScript

$('.box1').insertBefore('.box');