<html>
<head>
<style>
div {
border: 1px solid black;
margin: 5px;
}
</style>
</head>
<body>
<p>Click the button to add a background color to the second child element (index 1) of div.</p>
<button onclick="myFunction()">Try it</button>
<div id="myDIV">
<p>First p element</p>
<p>Second p element</p>
</div>
<script>
function myFunction() {
var c = document.getElementById("myDIV").children;
c[1].style.backgroundColor = "yellow";
}
</script>
</body>
<!-- Mirrored from www.w3schools.com/jsref/tryit.asp?filename=tryjsref_element_children2 by HTTrack Website Copier/3.x [XR&CO'2014], Mon, 27 Jan 2020 03:02:17 GMT -->
</html>