View Full Version : Swap content inside a div when link clicked

02-03-2012, 03:01 PM

I want to change the content of a <div> (or swap divs?)when a user clicks a link just below it.
What is the best method for doing this? It's only a small bit of html content inside the div that i need to swap when someone clicks a link just below it.


{html content 1}

(link to replace content 1 with hidden content 2)

Many thanks if you can help,


02-03-2012, 03:11 PM
Use javascript to switch display from none to inline or block using the onClick action.

ARCLite Studio
02-03-2012, 05:18 PM
<div id="mydiv"> This is the original content </div>
<a href="#" onClick="swap()">Link text Here</a>

<script type="text/javascript">
function swap() {document.getElementById("mydiv").innerHTML="NEW HTML CONTENT HERE";}

This should do what you need