Need help with mouse over effect

Discussion in 'JavaScript' started by rob7676, Nov 24, 2008.

  1. #1
    Ok here is my idea, imagine you goto a page for t-shirt designs and there is a blank white t on the screen and a group of sample thumbnails below it. No if you want to see the sample on the t-shirt you "in-theory" mouse over it and the image will appear on the t-shirt. How do I do it? I can make a simple mouse over but not make one that shows the over image in a different spot of the page. Can anyone please help me?
     
    rob7676, Nov 24, 2008 IP
  2. xlcho

    xlcho Guest

    Messages:
    532
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #2
    This is pretty simple actually :) You need to do something like that:
    You have an image that shows the big t-shirt, lets say it's code is this:
    <img src='bigimage.jpg' id='bigimgage'>
    Code (markup):
    Then you have the thumbnails of the other t-shirts. Their event handler can be this:
    <img src='other_pic_1.jpg' onmouseover='changePic(this.src)'>
    Code (markup):
    and the changePic() function:
    function changePic(newImage)
    {
      //all you do is access the bigimage element, which contains the blank t-shirt and change it's src property to point to the mouseovered one.
      document.getElementById('bigimage').src = newImage;
    }
    Code (markup):
     
    xlcho, Nov 24, 2008 IP