SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Wizard bronze trophy bigalreturns's Avatar
    Join Date
    Mar 2006
    Location
    The Wirral, England
    Posts
    1,294
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Simple Show/Hide Question

    I'm new to this whole javascript malarkey, and I'm trying to make a div show when a button is pressed. The code I'm using is as follows, but its not working...

    In <head> section
    Code:
    <script type="text/javascript">
    function showDiv(id)
    {
     div = document.getElementById(id);
     div.style.display = "block";
    } 
    </script>
    In <body>
    Code:
    <p><a href="#" title="Waste-Some-Time.com - Links By Category" onclick="showDiv("catdets")">Links By Category</a></p>
        <div id="catdets" style="display:none">
            <div class="linkcontainer">
            <a href="#">Cartoons</a>
            </div>
            <div class="linkcontainer">
            <a href="#">Games</a>
             </div>
        </div>
    Could you tell me what I'm doing wrong please?
    Thanks for your time,
    Alex
    "The proper function of man is to live - not to exist."
    Get a Free TomTom


  2. #2
    SitePoint Wizard
    Join Date
    Mar 2004
    Posts
    1,647
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    use single quotes inside the function when you call it


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •