<html >
<head >
<title >Javascript Change Div InnerHTML </title >
<script language="javascript" type="text/javascript" >
function changeDivHTML()
{
var previousInnerHTML = new String();
previousInnerHTML = document.getElementById('div1').innerHTML;
previousInnerHTML = previousInnerHTML.concat(" <h1 >New HTML Text added to the div HTML tag. </h1 >");
previousInnerHTML = previousInnerHTML.concat(" <p align=\"center\" >Paragraph child HTML element added <br / > to the div tag dynamically. </p >");
previousInnerHTML = previousInnerHTML.concat(" <span style=\"color:#ff0000\" >Span child HTML element added to the div tag dynamically. </span >");
document.getElementById('div1').innerHTML = previousInnerHTML;
}
</script >
</head >
<body >
<div id="div1" >
<b >innerHTML </b > placed inside the <b >div </b > element of HTML. <br / >
Javascript will change the innerHTML of this HTML div element.
</div >
<center >
<input type="button" value="Change Div innerHTML" onclick="changeDivHTML()" / >
</center >
</body >
</html >