...

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



treetops
02-03-2012, 04:01 PM
Hello

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.

E.g

<div>
{html content 1}
</div>

(link to replace content 1 with hidden content 2)

Many thanks if you can help,

Tree

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

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




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


This should do what you need



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum