I am in need of assistance here.
My goal is to display dynamic content within a div. Below you will find the code I currently have:
<script type="text/javascript"><!--
function AlterContentInContainer(id, content) {
var container = document.getElementById(id);
container.innerHTML = content;
}
//--></script>
<div id="example1div" style="padding:10px; text-align:left;">
<p>Content 1</p>
</div>
<p align="center"><a href="javascript:AlterContentInContainer('example1div','<p>Content 2</p>')">View another</a></p>
The current functionality allows for 'Content 1' to be replaced by 'Content 2' upon clicking "View another." However, my desired behavior is for subsequent clicks on the "View another" link to replace the div's content with new content like 'Content 3' when 'Content 2' is already displayed.
If anyone can assist me in solving this issue, I would greatly appreciate it.
Thank you in advance :)