gemzilla
07-18-2013, 12:36 PM
Hi,
I'm trying to create a read button on a website so that I can tidy up the web page. The text will be hidden by default and if a user clicks read more then they should get the rest of the text appear. I want multiple of these buttons to appear.
I have got the core of the code, I think, but when I had more of the same button to on web page, no matter what button I press it will always show the more info of the first instance. Hope I'm making sense.
this is my Java script and HTML code:
function ReverseDisplay() {
if(document.getElementById('more').style.display == "none") { document.getElementById('more').style.display = "block"; }
else { document.getElementById('more').style.display = "none"; }
}
<div id="morebutton" onclick='ReverseDisplay();'><a>Read More</a></div>
<div id="more" style="display:none;">more info</div>
The idea is that there will be multiple instances of the HTML code and the button that the user clicks will be the text related to that button.
Thanks
I'm trying to create a read button on a website so that I can tidy up the web page. The text will be hidden by default and if a user clicks read more then they should get the rest of the text appear. I want multiple of these buttons to appear.
I have got the core of the code, I think, but when I had more of the same button to on web page, no matter what button I press it will always show the more info of the first instance. Hope I'm making sense.
this is my Java script and HTML code:
function ReverseDisplay() {
if(document.getElementById('more').style.display == "none") { document.getElementById('more').style.display = "block"; }
else { document.getElementById('more').style.display = "none"; }
}
<div id="morebutton" onclick='ReverseDisplay();'><a>Read More</a></div>
<div id="more" style="display:none;">more info</div>
The idea is that there will be multiple instances of the HTML code and the button that the user clicks will be the text related to that button.
Thanks