Element item() Method - Use childNodes.item(index) to access child node - Javascript DOM

Javascript examples for DOM:Element item

Description

Element item() Method - Use childNodes.item(index) to access child node

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body><p>This is the first p element in body.</p>


<button onclick="myFunction()">Test</button>

<script>
function myFunction() {//w w  w  .  ja  v a2 s . c o m
    document.body.childNodes.item(0).innerHTML = "Changed!";
}
</script>

</body>
</html>

Related Tutorials