Title: Show/hide element scripting problem
Last modified: August 31, 2016

---

# Show/hide element scripting problem

 *  Resolved [darnoldy](https://wordpress.org/support/users/darnoldy/)
 * (@darnoldy)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/showhide-element-scripting-problem/)
 * I have a list in the sidebar of my site that I want to start out collapsed, and
   give the user the ability to show it— pretty standard stuff.
 * Here is my script:
 *     ```
       <script type="text/javascript" language="JavaScript"><!--
       		function ShowMemList() {
       			document.getElementById('members-hidable').style.display = "block";
       			document.getElementById('members-off').style.display = "block";
       			document.getElementById('members-on').style.display = "none";
       		}
   
       		function HideMemList() {
       			document.getElementById('members-hidable').style.display = "none";
       			document.getElementById('members-off').style.display = "none";
       			document.getElementById('members-on').style.display = "block";
       		}
   
       	//--></script>
       ```
   
 * Here is the html:
 *     ```
       <div id='member-controls'>
         <a href='' id='members-on' onClick='ShowMemList()'>(Show members list)</a>
         <a href='' id='members-off' onClick='HideMemList()'>(Hide members list)</a>
       </div>";
       <ul id='members-hidable'>
       ```
   
 * The “show” script works—except that immediately after, the page seems to reload
   and revert back to the original style attributes. I’ve never seen this happen
   when I have used this script on static pages. I this something WordPress is doing—
   and how do I make it stop?
 * Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [Clarion Technologies](https://wordpress.org/support/users/clarionwpdeveloper/)
 * (@clarionwpdeveloper)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/showhide-element-scripting-problem/#post-7386091)
 * Hello darnoldy,
 * Can you please share your website link so that I can check the issue.
 * Thanks
 *  Thread Starter [darnoldy](https://wordpress.org/support/users/darnoldy/)
 * (@darnoldy)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/showhide-element-scripting-problem/#post-7386102)
 * Sure…
    You can look at this page: [http://arnoldy.us/SWWA/events/](http://arnoldy.us/SWWA/events/)
   You will need to reduce the width of the viewport to small tablet or wide phone
   width to see it the collapse.
 * Thank you for your help.
 * –don
 *  [Clarion Technologies](https://wordpress.org/support/users/clarionwpdeveloper/)
 * (@clarionwpdeveloper)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/showhide-element-scripting-problem/#post-7386112)
 * Hello darnoldy,
 * The issue is the you have provided blank in href=”” attribute of a link so it
   refreshing the page when you click on the link.You need add the href=”#” for 
   those links this will solve your problem.
 * Thanks
 *  Thread Starter [darnoldy](https://wordpress.org/support/users/darnoldy/)
 * (@darnoldy)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/showhide-element-scripting-problem/#post-7386161)
 * Such a silly mistake!
 * Thank you for your help… the script now works as expected.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Show/hide element scripting problem’ is closed to new replies.

 * 4 replies
 * 2 participants
 * Last reply from: [darnoldy](https://wordpress.org/support/users/darnoldy/)
 * Last activity: [10 years, 1 month ago](https://wordpress.org/support/topic/showhide-element-scripting-problem/#post-7386161)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
