Javascript学习笔记(二)入门--捕获鼠标事件

onclick() 鼠标点击时触发事件
onmouseover() 鼠标进入此区域时触发事件
onmouseout() 鼠标离开区域时触发事件

<html>
<head> 
   <title> Mine  </title>
</head>
<body>
  <!--图片的读入以及跟随鼠标状态变化更改图片-->
  <img src = "wood.jpg" alt="tick" onmouseover="this.src='haha.jpg'" onmouseout="this.src='wood.jpg'"/>
  <!--点击按钮时弹出消息-->
  <input type="button" onclick="alert('You clicked the button!')" value="Click me"/>
</body>
</html>

猜你喜欢

转载自blog.csdn.net/where_is_my_keyboard/article/details/79965840