Jump to content

Display/hide buttons


Andrew R

Recommended Posts

Hi.  I’m using the following script to display/hide parts of the html on the page.  I use the span to make this work

 

<script type="text/javascript">
function showStuff(id) {
	document.getElementById(id).style.display = 'block';
}
function hideStuff(id) {
	document.getElementById(id).style.display = 'none';
}
</script>

 

<span id="deals" style="display: display;">
<<<<Html in here>>>
</span

 

To make it hide you click on the below link image.

 

<a href="#" onclick="hideStuff('deals'); return false;"><img src="images/hide.png" width="10" height="10" border="0"></a>

 

To make it display you click the below link image.

 

<a href="#" onclick="showStuff('deals'); return false;"><img src="images/show.png" width="10" height="10" border="0"></a>

 

When I click on the above button to hide or display the html how would I get the button to change from hide to show or vice versa? 

 

 

Any help and advice would be much appreciated  :)

 

Thanks

Link to comment
Share on other sites

Just hide and show the buttons as well

<a href="#" onclick="hideStuff('deals'); hideStuff('hide_link); showStuff('show_link'); return false;" id="hide_link"><img src="images/hide.png" width="10" height="10" border="0"></a>

<a href="#" onclick="showStuff('deals'); hideStuff('show_link); showStuff('hide_link');  return false;" id="show_link"><img src="images/show.png" width="10" height="10" border="0"></a>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.