1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Javascript Image switch

Discussion in 'Programming' started by plecosword, Sep 26, 2009.

  1. #1
    Hello, I am trying to get the image to switch on a td - table, and reaping x. It is for a navigation bar, I don't know how to have it switching. I hope Im making sense.
    I cannot do it in CSS because I can only apply a:hover to an anchor tag and when I do, the repeated image appears only behind the txt, not the whole image.
     
    plecosword, Sep 26, 2009 IP
  2. ohteddy

    ohteddy Member

    Messages:
    128
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    28
    #2
    you can use CSS to do this, and it's probably the preferred method of doing so.
    In css define:

    
    .navbar a {
    background-image : url(/images/foo.jpg);
    }
    
    .navbar a:hover {
    background-image : url(/images/bar.jpg);
    } 
    
    Code (markup):
    I have not tested this code. Incidentally if you're still not able to figure it
    out, do a search for "CSS Image rollovers" I'm sure you'll find some good
    examples.
     
    Last edited: Sep 27, 2009
    ohteddy, Sep 27, 2009 IP
  3. Traffic-Bug

    Traffic-Bug Active Member

    Messages:
    1,866
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    80
    #3
    Search for 'onmouseover image swap' and get the codes.
     
    Traffic-Bug, Sep 27, 2009 IP
  4. plecosword

    plecosword Peon

    Messages:
    26
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Its a repeating image, and I made it work!!! :) Thanks!!! it worked with css!
    
    .NavButton:hover
    
    HTML:
    Now just one more thing, is there a way to hyperlink the entire box (td tag) not just the txt. but really, thanks! I have been trying to figure that out for a while.
     
    plecosword, Sep 28, 2009 IP
  5. stickycarrots

    stickycarrots Peon

    Messages:
    4,513
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    0
    #5
    What if you add the <a href tag around the entire td tag? I typically use divs, in which case I think it'll work.
     
    stickycarrots, Sep 28, 2009 IP
  6. plecosword

    plecosword Peon

    Messages:
    26
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    No, that doesn't work at all :( I found this scrip though, I only understand half of it, but I cannot get it to work. the only thing I changed was the table id in the script, once

    http://radio.javaranch.com/pascarello/2005/05/19/1116509823591.html
     
    plecosword, Sep 28, 2009 IP