jquery插件使用教程 jquery插件的使用方法



文章插圖
jquery插件使用教程 jquery插件的使用方法

文章插圖
<!DOCTYPE html>
<html>
<head>
<meta charset=”utf-8″>
<title>33-jquery移入移出事件</title>
<style type=”text/css”> /*樣式開始*/
*{ /*表示 所選取的該元素以及其所屬的子元素 */
margin: 0; /*外邊距*/
padding: 0; /*內邊距*/
}
.father{ /* 選中class叫父親的div盒子*/
width: 200px; /* 寬:200像素*/
height: 200px; /* 高:200像素*/
background: red; /* 背景:紅色*/
}
.son{ /* 選中class叫兒子的div盒子*/
width: 100px; /* 寬:100像素*/
height: 100px; /* 高:100像素*/
background: #0000FF; /* 背景:藍色*/
}
</style>
<script src=http://www.mnbkw.com/jxjc/188621/”../static/js/jquery-3.6.0.js”>
<script>
$(function(){ /* jQuery 的入口函數 */
// alert(‘入口函數’) /* 入口函數沒有錯誤就會彈出 */
/*
mouseover mouseout 事件, 子元素被移入移出,也會觸發父元素的事件
*/
// $(“.father”).mouseover(function(){ /*選擇class叫父親的div的鼠標移入事件*/
// alert(‘鼠標進入了父親的盒子區域’) /* 彈出窗口’鼠標進入了父親的盒子區域’*/
// })
// $(“.father”).mouseout(function(){ /*選擇class叫父親的div的鼠標移出事件*/
// alert(‘鼠標移出了父親的盒子區域’) /* 彈出窗口’鼠標移出了父親的盒子區域’*/
// })
/*mouseenter mouseleave 事件, 子元素被移入移出,不會觸發父元素的事件 */
// $(“.father”).mouseenter(function(){ /*選擇class叫父親的div的鼠標移入事件*/
// alert(‘鼠標進入了父親的盒子區域’) /* 彈出窗口’鼠標進入了父親的盒子區域’*/
// })
// $(“.father”).mouseleave(function(){ /*選擇class叫父親的div的鼠標移出事件*/
// alert(‘鼠標移出了父親的盒子區域’) /* 彈出窗口’鼠標移出了父親的盒子區域’*/
// })
// $(“.father”).hover(function(){ /* 同時監聽鼠標移入移出的事件用hover 子元素被移入移出,不會觸發父元素的事件*/
// console.log(‘鼠標移入了’) /* 移入后調用*/
// }, function(){
// console.log(‘鼠標移出了’) /* 移出后調用*/
// })
$(“.father”).hover(function(){ /* 同時監聽鼠標移入移出的事件用hover 子元素被移入移出,不會觸發父元素的事件*/
console.log(‘鼠標移入移出了’) /*鼠標移入和移出都監聽了*/
})
})
</script>
</head>
<body>
<div class=”father”> <!– class叫父親的div盒子 –>
<div class=”son”> <!– class叫兒子的div盒子 –>
</div>
</div>
</body>
【jquery插件使用教程 jquery插件的使用方法】</html>