按钮变色变色变色

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript">
window.onload = function() {
    var obj = document.getElementsByTagName('input');
    for(var i = 0; i < obj.length; i ++) {
        if (obj[i].type.toLowerCase() == 'button') {
            obj[i].onmouseover = function() {
                this.style.backgroundColor = '#900';
                this.style.color = '#FFF';
            }
            obj[i].onmouseout = function() {
                this.style.backgroundColor = '';
                this.style.color = '';
            }
        }
    }
}
</script>
</head>
 
<body>
<input type="button" value="我是只按钮" />
</body>
</html>

原文地址:https://www.cnblogs.com/code81/p/4148508.html