css有类似有失去焦点设置样式的功能吗

html-css016

css有类似有失去焦点设置样式的功能吗,第1张

css2有获得焦点的选择器:

input:focus {...} //当input元素获得焦点时就会套用这个样式

也就是说当input元素失去焦点就会恢复为原来的样式。因此只需给同一类元素设置默认样式和获得焦点时的样式即可实现你的目的。

<img src="img/contact.gif" onmouseover="this.src='img/banner.jpg'" onmouseout="this.src='img/contact.gif'">

<table width="760" border="1">

<tr onmouseover="this.style.backgroundColor='red'" onmouseout="this.style.backgroundColor='blue'">

<td>鼠标移过来看看

</td>

</tr>

</table>

用鼠标失焦和得焦事件实现

把图片换一下哦~~