Display/Hide function not working in Firefox

Discussion in 'JavaScript' started by zenweezil, Jun 29, 2007.

  1. #1
    I have been using this javascript for awhile now, and just realized that it does not work in Firefox, any ideas why?

    <script language="JavaScript">
    <!--
    function Show_Stuff(Click_Menu)
    // Function that will swap the display/no display for
    // all content within span tags
    {
    if (Click_Menu.style.display == "none")
    {
    Click_Menu.style.display = "";
    }
    else
    {
    Click_Menu.style.display = "none";
    }
    }
    -->
    </script>


    The javascript is getting called with a link like this:
    <a href="javascript:Show_Stuff(display1)">Click Here</a>

    And then that will show or hide what is in this span:
    <span ID="display1" style="display: none"> STUFF HERE </span>

    This works fine in IE. Thanks in advance.
     
    zenweezil, Jun 29, 2007 IP
  2. Mike H.

    Mike H. Peon

    Messages:
    219
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #2
    <script type="text/javascript">
    
    function Show_Stuff(Click_Menu_ID){
    
    	var nSpan = document.getElementById(Click_Menu_ID);
    	if (nSpan.style.display == "none")
    		{
    		 nSpan.style.display = "";
    		}
    	else
    		{
    		 nSpan.style.display = "none";
    		}
    }
    
    </script>
    Code (markup):

    <a href="#" onclick="Show_Stuff('display1');return false">Click Here</a>
    Code (markup):

    <span id="display1" style="display:none"> STUFF HERE </span>
    Code (markup):
     
    Mike H., Jun 29, 2007 IP
  3. zenweezil

    zenweezil Well-Known Member

    Messages:
    339
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    138
    #3
    Thanks - works perfectly!

    I see now where my lack of attention to detail was to blame.
     
    zenweezil, Jun 29, 2007 IP
  4. Mike H.

    Mike H. Peon

    Messages:
    219
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #4
    You're welcome, but I don't see how you failed to pay attention to detail. I learn new things all the time.
     
    Mike H., Jun 29, 2007 IP