简体   繁体   English

HTML / DOM:鼠标事件不起作用

[英]HTML/DOM: Mouse-events not working

In IE9, this code does not change the size of button as intended... 在IE9中,此代码不会按预期更改按钮的大小...

<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. 您的代码不仅在IE9中有效,而且在FF13和Chrome19中也不起作用。 To workaround this problem, you can try to replace your m1() and m2() functions as: 要解决此问题,您可以尝试将m1()m2()函数替换为:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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