实例代码“Ctrl+/”提示“F11/ESC”全屏 返回 格式化 恢复 运行
x
 
1
<!DOCTYPE html>
2
<html>
3
<head>
4
<script src="https://libs.baidu.com/jquery/1.10.2/jquery.min.js">
5
</script>
6
<script>
7
$(document).ready(function(){
8
  $("p").mouseover(function(){
9
    $("p").css("background-color","yellow");
10
  });
11
  $("p").mouseout(function(){
12
    $("p").css("background-color","lightgray");
13
  });
14
  $("#btn1").click(function(){
15
    $("p").mouseover();
16
  });  
17
  $("#btn2").click(function(){
18
    $("p").mouseout();
19
  }); 
20
});
21
</script>
22
</head>
23
<body>
24
25
<p>Move the mouse pointer over this paragraph.</p>
26
<button id="btn1">Trigger mouseover event</button><br>
27
<button id="btn2">Trigger mouseout event</button>
28
29
</body>
30
</html>