Onmouseover更改Button控件的背景颜色 [英] Onmouseover change the backcolor of a Button control

查看:144
本文介绍了Onmouseover更改Button控件的背景颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我想使用Javascript更改按钮MouseOver事件上按钮控件的背景颜色。

Hi,

I want to change the backcolor of a button control on MouseOver event of a button using Javascript.

推荐答案

我们得到了Google Inc.通过www.google.com的非常好的支持,您可以利用它。此外,您可以使用css更改鼠标悬停按钮:



We have very good support from Google Inc. through www.google.com,you can make use of that.Further,you can change button on mouse hover using the css like:

#yourbuttonid:hover 
{
    background:#ff0000;
}





您也可以参考以下链接



更改鼠标悬停按钮的行为,如背景颜色,文字颜色等


javascript:

javascript:
<script type="text/javascript">
    function GetBackColor() {
        document.getElementById("testButton").setAttribute("style", "background-color:green");
    }

    function RemoveColor() {
        document.getElementById("testButton").removeAttribute("style");
    }
    </script>





按钮:

< input type =buttonid = testButtononmouseover =GetBackColor()value =testonmouseout =RemoveColor()/>



button:
<input type="button" id="testButton" onmouseover="GetBackColor()" value="test" onmouseout="RemoveColor()"/>


这篇关于Onmouseover更改Button控件的背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆