Toggle by image on show-hide

Discussion in 'HTML & Website Design' started by Peuplarchie, Apr 19, 2009.

  1. #1
    Good day to you all,
    I'm working on a code which is part of a menu.
    That part of code is the Toggle show/hide function, with image.

    I can right now make the show/hide toggle, but the image don't change from + to -.

    How can I make my image change depending if Show or hide ?




    
    
    function Toggle(li) {
    var elem = document.getElementById(li);
    if(!elem)return; // in case element doesn't exists in document;
    elem.style.display = (elem.style.display != "none")? "none": "block";
    
    
    }
    
    
    Code (markup):
    
    
    <img src="plus_icon.gif"  onclick="Toggle('Image_folder'); return false;" />
    
    
    HTML:

    Thanks !
     
    Peuplarchie, Apr 19, 2009 IP
  2. Mockup-Markup

    Mockup-Markup Peon

    Messages:
    32
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Check out the jQuery library makes javascripting tasks way easier!
     
    Mockup-Markup, Apr 20, 2009 IP