Results 1 to 4 of 4

Thread: Div on click

  1. #1
    Join Date
    Nov 2007
    Posts
    151
    Thanks
    67
    Thanked 0 Times in 0 Posts

    Default Div on click

    Hi,

    I have a link,
    and I want to create such a floating div that will be seen after clicking on the link. The div should include a Close link, that will hide it.
    Something like:


    Thanks!

  2. #2
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Quick n' Dirty:
    Code:
    <style type="text/css">
    #hello {
      display: none;
      position: absolute;
      top: 300px;
      left: 100px;
      height: 100px;
      width: 100px;
      border: 1px solid black;
      background: lightblue;
    }
    </style>
    <a href="javascript:void(0)"  onclick="document.getElementById('hello').style.display='block'">SHOW</a>
    <div id="hello"><a href="javascript:void(0)" onclick="this.parentNode.style.display='none'">BLAH</a></div>
    Jeremy | jfein.net

  3. The Following User Says Thank You to Nile For This Useful Post:

    d-machine (08-23-2009)

  4. #3
    Join Date
    Nov 2007
    Posts
    151
    Thanks
    67
    Thanked 0 Times in 0 Posts

    Default

    Thank you very much!
    However, is there a way to position it so it to appears always at to bottom of the link,
    (since right now it depends on the size of the window)?

  5. #4
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Here:
    Code:
    <style type="text/css">
    #hello {
      display: none;
      position: absolute;
      height: 100px;
      width: 100px;
      border: 1px solid black;
      background: lightblue;
    }
    </style>
    <script type="text/javascript">
    var show = function (toggleID, me){
      toggleID.style.left = me.offsetLeft;
      toggleID.style.top = me.offsetTop + me.fontSize;
      toggleID.style.display = "block";
    };
    </script>
    <a href="javascript:void(0)"  onclick="show(document.getElementById('hello'), this);">SHOW</a>
    <div id="hello"><a href="javascript:void(0)" onclick="this.parentNode.style.display='none'">BLAH</a></div>
    Jeremy | jfein.net

  6. The Following User Says Thank You to Nile For This Useful Post:

    d-machine (08-23-2009)

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
  •