网页制作中 当鼠标放在button按钮上时 按钮颜色改变 如何实现?

如题所述

插入代码<button onmouseover="this.style.backgroundColor='red';" onmouseout="this.style.backgroundColor='';" >button</button>即可实现。

Button 

鼠标上的一个活动片,用于激活一些功能。旧式的鼠标模型只有一个按钮;新式一般有两个或更多个按钮

【英】On a mouse, amovable piece that is pressed to activate some function. Older mouse models have only one button; newer modelstypically have two or more.

html标签

HTML <button> 标签

定义和用法

<button> 标签定义一个按钮。

在 button 元素内部,您可以放置内容,比如文本或图像。这是该元素与使用 input 元素创建的按钮之间的不同之处。

<button> 控件 与 <input type="button"> 相比,提供了更为强大的功能和更丰富的内容。<button> 与 </button> 标签之间的所有内容都是按钮的内容,其中包括任何可接受的正文内容,比如文本或多媒体内容。

例如,我们可以在按钮中包括一个图像和相关的文本,用它们在按钮中创建一个吸引人的标记图像。

唯一禁止使用的元素是图像映射,因为它对鼠标和键盘敏感的动作会干扰表单按钮的行为。

请始终为按钮规定 type 属性。Internet Explorer 的默认类型是 "button",而其他浏览器中(包括 W3C 规范)的默认值是 "submit"。

实例

<html>

<head>

<script type="text/javascript">

function whichButton(event)

{

if (event.button==2)

{

alert"You clicked the right mouse button!")

}

else

{

alert"You clicked the left mouse button!")

}

}

</script>

</head>

<body "whichButton(event)">

<p>Click in the document. An alert box will

alert which mouse button you clicked.</p>

</body>

</html>

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