js操作dom

<html>
  <div id="i">
    <div id="i2">22</div>
  </div>
</html>
<script>
  var i = document.getElementById("i");
  var i2 = document.getElementById("i2");
  var i1 = document.createElement("a");
  i.insertBefore(i1,i2); 
  alert(document.getElementById("i").innerHTML)
</script>

 

你可能感兴趣的:(js操作dom)