SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot Fokebox's Avatar
    Join Date
    Aug 2011
    Posts
    131
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Hide text button! Plese help to finish it!

    Well, this is a simple code that hides the text! So please help me to change the plus.gif image to minus.gif image on click
    Thanks for help

    HTML Code:
    <script> 
    function op(obj) { 
    x=document.getElementById(obj); 
    if(x.style.display == "none") x.style.display = "block"; 
    else x.style.display = "none" 
    } 
    </script>  
     
    <a href="Internet">Internet</a>
    <a href="#" onClick="op('div1'); return false;">
    <img src="plus.gif" style="height: 10px; width: 10px; border: medium none"></a><ul>
    <div id="div1" style="display:none">
    <li><a href="Internet Portals">Internet Portals</a></li>
    <li><a href="Internet Access">Internet Access</a></li>
    <li><a href="Internet Cafe">Internet Cafe</a></li>
    <li><a href="Internet Shop">Internet Shop</a></li>
    </div>
    </ul>  
    Submit your URL for free at Open Directory www.livewebmap.com

  2. #2
    Non-Member Max Height's Avatar
    Join Date
    Dec 2011
    Posts
    303
    Mentioned
    6 Post(s)
    Tagged
    1 Thread(s)
    You can give the <img> an id so you can access it with getElementById() to change the value of the <img>'s src attribute.

  3. #3
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,526
    Mentioned
    83 Post(s)
    Tagged
    3 Thread(s)
    You could use a CSS sprite, so that you only need to change a class name to show the other part of it.

    http://css-tricks.com/css-sprites/
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


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
  •