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

问题描述





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

Hi,

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

推荐答案

#yourbuttonid:hover
{
    background:#ff0000;
}





您也可以参考以下链接




<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控件的背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-16 20:30
查看更多