This is one of the way that you should try to implement and execute it and I will suggest you work with this below written code and if you any problem related to implementation and execution then please let me know..for further information you can post next reply ...
Code:
<html>
<head>
<title>Change div content</title>
<style>
div, a { padding:3px; margin:3px 3px 33px 3px; }
#scriptVars1 { border:1px solid red; }
#scriptVars2 { background:green; }
#bob { border:3px solid blue; }
</style>
<script>
function changeDivContent( nameOfDiv, newContent )
{
var div = document.getElementById( nameOfDiv );
if( div )
{
div.innerHTML = newContent;
}
}
</script>
</head>
<body>
<a href="#" onclick="changeDivContent( 'scriptVars1', 'This is the new Content' )">Click here to change the content of the div below</a><a href="#" onclick="changeDivContent( 'scriptVars1', 'This is the new new Content' )">Click here to change the content of the div below again</a>
<div id="scriptVars1">
Script is here!
<script>
</script>
</div>
<a href="#" onclick="changeDivContent( 'scriptVars2', 'This is the new Content' )">Click here to change the content of the div following</a><a href="#" onclick="changeDivContent( 'scriptVars2', 'This is the new new Content' )">Click here to change the content of the div following now</a>
<div id="scriptVars2">
Script is here!
<script>
</script>
</div>
<a href="#" onclick="changeDivContent( 'bob', 'This is the new Content' )">Just click here to change the content of the div following</a><a href="#" onclick="changeDivContent( 'bob', 'This is the newly created Content' )">Just click here to change the content of the div following now</a>
<div id="bob">
Script is here!
<script>
</script>
</div>
</body>
</html>
Bookmarks