SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: Links - Classes

Hybrid View

  1. #1
    Free me php klassicd's Avatar
    Join Date
    Sep 2001
    Location
    San Diego
    Posts
    509
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Links - Classes

    I would like for my links to work the same way as this image below. Its basically a outline im trying to make for my site. All my images have this type of coding.

    <img src="images/widget_plus.gif" id="Out1" class="Outline" style="cursor: hand" width="11" height="11">

    What would i do to the link tag to make them work the same way. Here is the javascript. I tried making it a link like:
    <a id="Out1" class="Outline" style="cursor: hand"> But that didnt work out too well. Any other ideas?

    <script language="JavaScript">
    function clickHandler() {
    var targetid, srcElement, targetElement;
    srcElement = window.event.srcElement;
    if (srcElement.className == "Outline") {
    targetid = srcElement.id + "d";
    targetElement = document.all(targetid);
    if (targetElement.style.display == "none") {
    targetElement.style.display = "";
    srcElement.src = "images/widget_minus.gif";
    } else {
    targetElement.style.display = "none";
    srcElement.src = "images/widget_plus.gif";
    }
    }
    }

    document.onclick = clickHandler;

    </script>

    Full page source is located at http://projects.kfoolio.com/topics.php

  2. #2
    Sultan of Ping jofa's Avatar
    Join Date
    Mar 2002
    Location
    SvÝ■jˇ­
    Posts
    4,080
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What is it that's not working?

    The a tag has no src attribute => will fail
    Check if srcElement.tagName == "IMG" before trying to access .src


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
  •