Change image dimensions

Discussion in 'JavaScript' started by XandroZ, Apr 1, 2008.

  1. #1
    I need to change the dimensions of an image when mouse is over

    <script Language="JavaScript">
    function ChangeImage (ImageName) {
    this.width=30px;
    }
    </script>
    </head>
    <div class="container">
      <ul>
      <li><a  href="#"><img src="images/home.png" alt="home"  onmouseover="ChangeImage(images/home.png)"/></a></li> 
      <li><a  href="#"><img src="images/email.png" alt="contact" /></a> </li> 
      <li><a  href="#"><img src="images/portfolio.png" alt="portfolio" /></a> </li> 
      <li><a  href="#"><img src="images/music.png" alt="music" /></a> </li> 
      <li><a  href="#"><img src="images/video.png" alt="video" /></a> </li> 
      <li><a  href="#"><img src="images/history.png" alt="history" /></a> </ul>
    </div>
    <body>
    Code (markup):
     
    XandroZ, Apr 1, 2008 IP
  2. KatieK

    KatieK Active Member

    Messages:
    116
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    58
    #2
    I don't think you're using "this" quite correctly. Try deleting the script block altogether, and make your images like this:

    
    <img src="images/home.png" alt="home" onmouseover="this.width='60';" />
    
    Code (markup):
     
    KatieK, Apr 1, 2008 IP
  3. XandroZ

    XandroZ Peon

    Messages:
    395
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #3
    thanks for your solution,that was only for a test
    basicaly I am trying to built a function that when exist a mouseover event over a image, the image dimension will remain the same and to change
    the other images, to make them smaller, so I can float a div with text (description) near (to the right) the image where the mouse is over.
     
    XandroZ, Apr 1, 2008 IP
  4. temp2

    temp2 Well-Known Member

    Messages:
    1,231
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    150
    Digital Goods:
    2
    #4
    really? I think it must be
     
    temp2, Apr 1, 2008 IP
  5. Dondon2d

    Dondon2d Peon

    Messages:
    3,193
    Likes Received:
    146
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Yes, you are very correct.
     
    Dondon2d, Apr 1, 2008 IP