www.webdeveloper.com
Results 1 to 5 of 5

Thread: [RESOLVED] change size when mouse move over

  1. #1
    Join Date
    Mar 2009
    Posts
    16

    resolved [RESOLVED] change size when mouse move over

    Hello everyone,
    I want to change the size of the image when my mouse moves over it. I write some code but doesn't work.

    In the page HTML:
    HTML Code:
    <img src="11-1.bmp" name="b1" id="b2" style="width:40px; height:30px;" onmouseover="mouseOver()" onmouseout="mouseOut()"/>
    And I import the code in the <head>:
    HTML Code:
    <head>
    <script type="text/javascript" src="changeImg.js">
    </script>
    </head>
    this is the code in the js document:
    Code:
    function mouseOver()
    {
    document.document.getElementById("b2").style.width=80;
    document.document.getElementById("b2").style.height=60;
    }
    function mouseout().....
    when I move my mouse over the pic, nothing happened, but if I test with:
    Code:
    function mouseOver()
    {
    alert("something")
    }
    the window of alert works normally. And I have tested with firefox, safari, so it is not the problem of browser.

    So, what happened? HTML can't accept the of changing size like this?

    Thank you very much!

  2. #2
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    Code:
    function mouseOver()
    {
    document.getElementById("b2").style.width=80+"px";
    document.getElementById("b2").style.height=60+"px";
    }
    At least 98% of internet users' DNA is identical to that of chimpanzees

  3. #3
    Join Date
    Mar 2009
    Posts
    16

    Wink

    Quote Originally Posted by Fang View Post
    Code:
    function mouseOver()
    {
    document.getElementById("b2").style.width=80+"px";
    document.getElementById("b2").style.height=60+"px";
    }
    Thank you for you reply.
    Did you try it?
    I tried, it doesn't work.

  4. #4
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    It works providing the id is unique.
    At least 98% of internet users' DNA is identical to that of chimpanzees

  5. #5
    Join Date
    Mar 2009
    Posts
    16
    Quote Originally Posted by Fang View Post
    It works providing the id is unique.
    The reason is that I use Xhtml, so it doesn't work.
    I try with html, it is good.
    Thank you!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles