js dom manipulation

by sramnan

HTML

<label id="sonia" name="text">sonia</label>
<ul id="test">
  <li>black</li>
  <li>dark blue</li>
</ul>
<ul id="test1">
<li><a href="http://www.google.com">black11</a></li>
  <li>dark 11blue</li>
</ul>

JavaScript

// create a   <script>
// run this function when the document is loaded

// create a couple of elements in an otherwise empty HTML page
var heading = document.createElement("h1");
var heading_text = document.createTextNode("Big Head!");
heading.appendChild(heading_text);
document.body.appendChild(heading);
var label = document.getElementById("test1");
console.log(label);
label.addEventListener("click", function(e) {
  console.log(event.target.getAttribute("href"));
  event.preventDefault();
})
label.remove();
console.log(label.firstElementChild.innerHTML);
console.log(label.nextElementSibling)
console.log(label.tagName);