javascript onclick

Discussion in 'Scripts' started by therearentanynamesleft, Jun 5, 2008.

  1. #1
    hello, i want to change the 'display' in a css file.

    basically, i have two classes in a css file, 'Parent' and 'sub'.

    i would like to make a script that when you click a link in class 'parent' then a specified link(s) in class sub would become visible.

    any ideas?

    -Regards
    CONTE
     
    therearentanynamesleft, Jun 5, 2008 IP
  2. vidal

    vidal Well-Known Member

    Messages:
    186
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    145
    #2
    Hi, try this one

    
    <html>
    <head>
    <title>Show/Hide ID</title>
    <script language=javascript>
    function showhide(id)
    {
    if(id == "sub")
    {
    document.getElementById('sub_yes').style.display = "none";
    document.getElementById('sub_no').style.display = "block";
    }
    else
    {
    document.getElementById('sub_yes').style.display = "block";
    document.getElementById('sub_no').style.display = "none";
    }
    }
    </script>
    </head>
    <body>
      <a href="javascript:showhide('sub')" id="sub_yes"> Parent</a>
    	<br>
      <a href="javascript:showhide('other')" id="sub_no" style="display:none"> Subitems</a>
    </body>
    </html>
    
    Code (markup):
     
    vidal, Jun 6, 2008 IP