Exchange content inside of all DIV elements
A simple example of exchanging the content inside of all
elements.
<!DOCTYPE html>
<html>
<head>
<style>
body {
margin: 0px;
padding: 0px;
}
</style>
</head>
<body>
<div class="first">
This is my first DIV
</div>
<div class="second">
This is my second DIV
</div>
<div class="second">
This is my third DIV
</div>
<script>
var myDivs = document.getElementsByTagName("div");
for(var i = 0; i < myDivs.length; i++){
myDivs[i].innerHTML = "This content was printed inside all of your DIVS :)";
}
</script>
</body>
</html>