SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Non-Member wulf's Avatar
    Join Date
    Jul 2006
    Posts
    217
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    what am i doing wrong? trying to make div hidden on click.

    I can do the whole onclick thing automatically with dreamweaver unfortunately what I'm using it for doesn't allow javascript tags in the header so I'm trying to do it without... it just doesn't seem to be working.

    Code:
    <a href="#" onclick="javascript:bla.visibility=hidden">asf</a></p>
    <div id="bla" style="visibility:visible">
    <p> test div </p>
    </div>

  2. #2
    SitePoint Wizard
    Join Date
    Dec 2003
    Location
    USA
    Posts
    2,582
    Mentioned
    29 Post(s)
    Tagged
    0 Thread(s)
    You can't just do bla.visibility. Also, it is bla.style.visibility. You need to do: document.getElementById('bla').style.visibility = 'hidden' instead.

    Also, the style="visibility:visible" isn't really necessary.

    So, it needs to be like this:
    Code:
    <p><a href="#" onclick="javascript:document.getElementById('bla').style.visibility='hidden'">asf</a></p>
    <div id="bla">
    <p>test div</p>
    </div>

  3. #3
    SitePoint Enthusiast
    Join Date
    Dec 2007
    Posts
    66
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    But get rid of the "javascript:" part in your onclick handler. There's no need.

    onclick="javascript:document.getElementById('bla').style.visibility='hidden'"

    becomes

    onclick="document.getElementById('bla').style.visibility='hidden'"


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
  •