Pop Stack
Pop Stack

Reputation: 944

HTML/DOM: Mouse-events to change button

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>

Upvotes: 0

Views: 244

Answers (2)

Andrew D.
Andrew D.

Reputation: 8220

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";
}​

Upvotes: 1

Neji
Neji

Reputation: 6839

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

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

this worked with me

Upvotes: 1

Related Questions