简体   繁体   中英

HTML/DOM: Mouse-events not working

In IE9, this code does not change the size of button as intended...

<html><head>
<script language="JavaScript">
    function fun1()
    {
        alert("clicked");
        document.form1.chk1.disabled=true;
    }
    function m1()
        {
            document.form1.chk1.width=60;
        }
    function m2()
        {
            document.form1.chk1.width=40;
        }
</script>
</head><body>
<form name="form1"><!-- creating radio button group -->
    <input type="button" name="chk1" value="red" onClick="fun1()"
    onMouseOver="m1()" onMouseOut="m2()">
</form>
</body></html>

well there was this style attribute missing in your code. try replacing this

document.form1.chk1.style.width="60%";

this worked with me

Your code does not work not only in IE9 but, for example, in FF13 and Chrome19. To workaround this problem, you can try to replace your m1() and m2() functions as:

function m1()
{
    document.form1.chk1.style.width=60+"px";
}
function m2()
{
    document.form1.chk1.style.width=40+"px";
}​

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM