• Resolved darnoldy

    (@darnoldy)


    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)
  • Hello darnoldy,

    Can you please share your website link so that I can check the issue.

    Thanks

    Thread Starter darnoldy

    (@darnoldy)

    Sure…
    You can look at this page:
    https://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

    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

    (@darnoldy)

    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.