abstrait:<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>jquery的事件函數(shù)</title> <script type=&
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>jquery的事件函數(shù)</title>
<script type="text/javascript" src="jquery-3.3.1.min.js"></script>
</head>
<body>
<script>
// 在jquery中是以調(diào)用事件函數(shù)的方式來觸發(fā)事件的,如js中的onclick事件,在jquery中用click()來替代
//簡(jiǎn)單的理解:事件方法會(huì)觸發(fā)匹配元素的事件,或者將函數(shù)綁定到所有匹配元素的某個(gè)事件
// ready() 當(dāng)文檔對(duì)象模型加載完成,觸發(fā)事件==js的onload
//不可以與<body onload="">一起使用
// $(document).ready(function(){
//
// })
//blur()當(dāng)失去焦點(diǎn)時(shí)觸發(fā)==onblur
//change()當(dāng)元素的值發(fā)生改變
//click()點(diǎn)擊事件
$(document).ready(function(){
// $('input').blur(function(){
// $('input').css('background','red')
// })
// $('input').focus(function(){
// $('input').css('background','blue')
// })
// $('input').change(function(){
// $('input').css('background','pink')
// })
// $('button').click(function(){
// $('div').css('background','pink')
// })
// $('div').dblclick(function(){
// $(this).css('background','pink')
// })
// $(document).mousemove(function (aa) {
// $('span').text('x: '+aa.pageX+'y: '+aa.pageY)
// })
// a=0;
// $(window).resize(function(){
// //alert('窗口被調(diào)整大小')
// $('b').text(a++)
// })
// $('div').mouseover(function(){
// $(this).css('background','pink')
// })
// $('div').mouseenter(function(){
// $(this).css('background','pink')
// })
// $('div').mouseleave(function(){
// $(this).css('background','blue')
// })
// $('div').mouseout(function(){
// $(this).css('width','50px')
// })
// $('div').mousedown(function(){
// $(this).css('width','50px')
// })
$('div').mouseup(function(){
$(this).css('width','50px')
})
})
</script>
<input type="text" name="">
<!--<div style="width:100px;height:100px;background: red;margin-top: 20px;"></div>-->
<!--<button>點(diǎn)擊</button>-->
<!--<div>-->
<!--當(dāng)前鼠標(biāo)的位置:<span></span>-->
<!--</div>-->
<!--<div>-->
<!--頁面被調(diào)整次數(shù):<b></b>-->
<!--</div>-->
<div style="width:100px;height:100px;background: red;">測(cè)試</div>
</body>
</html>
理解:類似于js中的事件,只是寫法不同,比js方便