HTML问题 鼠标经过按钮 改变按钮背景色与字体颜色

<input type="button" name="SubmitS" value=" 查看更多 " class="adminbutton" onMouseOut="this.style.backgroundColor=''" onMouseOver="this.style.backgroundColor='#b79855' " style="height:30px;padding-top:1px; width: 150" >

其中onMouseOver="this.style.backgroundColor='#b79855' " 只是改变了经过的背景色.如果想同时改变字体颜色应该怎么写?

试试:

onMouseOver = function(){
    this.style.backgroundColor = '#b79855';
    this.style.color = 'red';
}

追问

意思是onMouseOver=""不能直接改两个属性? 一定需要另写一个function?

追答

可以直接两个一起写,用分号隔开。如:

onMouseOver="this.style.backgroundColor='#b79855'; this.style.color = 'red';"

温馨提示:答案为网友推荐,仅供参考