How to create and add a new div inside parent div(“mainDiv”) but before the child div(“child”) of parent div(“maindiv”) using InsertBefore


How to create and add a new div inside parent div(“mainDiv”) but before the child div(“child”) of parent div(“maindiv”) using InsertBefore

<div id="mainDiv">
    <div class="row" id="child">
  </div>
</div>


var p = document.getElementById(“mainDiv”);
var html=(”<div>puja</div>”);
var exNode = document.getElementById("child");
var newElement = document.createElement(“<div>”);
newElement.setAttribute('id', “elementId”);
newElement.innerHTML = html;
p.insertBefore(newElement, exNode);

Comments

Popular posts from this blog

Kendo Control(Dynamics)

Override Authorize Filters in MVC

Form Validation