abstrak:<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0">&
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>jQuery事件切換</title>
<script src="jquery/jquery-3.3.1.js"></script>
<style>
div{width: 400px;height: 200px;margin:50px auto;background: #ccc;text-align: center;line-height: 200px; }
button{margin: 5px;}
</style>
</head>
<body>
<script>
$(document).ready(function(){
$('#a').click(function(){
$('div').hide(1500)
})
$('#b').click(function(){
$('.box1,.box').show(1500)
})
$('.box1').mouseover(function(){
$('.box1').css('background','red')
})
$('.box1').mouseout(function(){
$('.box1').css('background','#ccc')
})
$('.box1').mouseleave(function(){
$('.box1').css('color','#fff')
})
$('.box1').mousedown(function(){
$('.box1').css('background','#000')
})
$('.box1').mouseup(function(){
$('.box1').css('background','#ccc')
})
$('.box').hover(function(){
$(this).css('border','10px solid blue')
},
function () {
$(this).css('border','2px solid red')
}
)
$('#c').click(function(){
$('div').toggle()
})
})
</script>
<div class="box">我是神奇的hover</div>
<div class="box1">我是燈神,可以幫你完成2個(gè)功能!</div>
<button id="a">點(diǎn)我隱藏</button>
<button id="b">點(diǎn)我顯示</button>
<button id="c">我比他兩厲害</button>
</body>
</html>
Guru membetulkan:天蓬老師Masa pembetulan:2019-02-12 12:37:40
Rumusan guru:jQuery的DOM操作功能非常強(qiáng)大, 結(jié)合 實(shí)際案例,體會(huì)會(huì)更深些