Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: onclick

  1. #1
    New Coder
    Join Date
    Feb 2005
    Location
    France
    Posts
    89
    Thanks
    0
    Thanked 0 Times in 0 Posts

    onclick

    Hello again everybody

    I've got:

    Code:
    function appear() 
    {
    document.getElementById('content').innerHTML = ("test");
    }
    and:

    Code:
    <a href="javascript:void(0)" onclick="appear();"><img src="images/note.gif" name="note" alt="Note" border="0" width="191" height="21"></a>
    followed by:

    Code:
    <span id="content"></span>
    It does work and then I press the image-link the content appears below the link.

    However, I wonder if it is possible to make the content disappear when I click on the same image-link for the second time? i.e. I click once - the content appears, I click second time - the content disappears?

    If you have an idea on how it could be done, please drop me a hint,
    Thank you in advance,
    imatus

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    PHP Code:
    function appear() 
    {
    var 
    obj document.getElementById('content');
    obj.innerHTML = (obj.innerHTML=='')?'test':'';

    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #3
    New Coder
    Join Date
    Feb 2005
    Location
    France
    Posts
    89
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you very much, Kor


  •  

    Posting Permissions

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