abstrait:<!DOCTYPE html><html><head> <meta charset="utf-8"> <title>JQuery事件</title> <script type="text/javascript" src="jquery.min.js">&l
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JQuery事件</title>
<script type="text/javascript" src="jquery.min.js"></script>
<style type="text/css">
div,p{
width: 100px;
height: 100px;
border: 1px solid #ccc;
}
</style>
</head>
<body>
<!--div>
當(dāng)前鼠標(biāo)的位置: <span></span>
</div>
<div>
頁面被調(diào)整大小的次數(shù) <b></b>
</div-->
<!-- hover 事件 -->
<div></div>
<p></p>
<button>顯示隱藏</button>
<script type="text/javascript">
$(document).ready(function(){
// mouseover(); 鼠標(biāo)移動至上方時發(fā)生
// mouseenter(); 鼠標(biāo)經(jīng)過時發(fā)生
// mousemove(); 鼠標(biāo)再元素種移動時
// mouseleave() 鼠標(biāo)離開的時候
// mouseout 鼠標(biāo)指針離開元素時
// mousedown 鼠標(biāo)移動到元素上方并按下鼠標(biāo)按鍵時
// mouseup 在元素上松開鼠標(biāo)按鍵時
// resize 調(diào)整當(dāng)前瀏覽窗口大小時
// pageX 鼠標(biāo)相對于文檔左邊緣 event.pageX event:必須 參數(shù)來自事件綁定函數(shù)。
// pageY 相對于文檔的上邊緣 event.pageY event:必須
// 鼠標(biāo)在頁面中移動時發(fā)生的事件
/*$(document).mousemove(function(a){
$('span').text('X:'+a.pageX+'Y:'+a.pageY);
})
var a=1;
$(window).resize(function(){
$('b').text(a++);
//alert('窗口被調(diào)整');
})*/
// houver(over,out)
// over 鼠標(biāo)移上元素上要觸發(fā)的一個函數(shù),
// out 鼠標(biāo)移出元素上要觸發(fā)的一個函數(shù)
$('div').hover(function(){
$(this).css('background','red');
},function(){
$(this).css('background','blue');
})
// toggle 如果元素是可見的就隱藏,否則相反
$('button').click(function(){
$('p').toggle();// 顯示隱藏
})
})
</script>
</body>
</html>
Professeur correcteur:滅絕師太Temps de correction:2019-03-23 13:16:37
Résumé du professeur:記筆記的時候注意一點(diǎn)哦!hover都敲錯啦!