Javascript study notes (2) Getting started - capturing mouse events

onclick() triggers an event when the mouse is clicked
onmouseover() triggers an event when the mouse enters the area
onmouseout() triggers an event when the mouse leaves the area

<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>

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324479895&siteId=291194637