jquery事件切换之作业篇

原创 2019-02-12 12:19:21 314
摘要:<!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个功能!</div>

<button id="a">点我隐藏</button>

<button id="b">点我显示</button>

<button id="c">我比他两厉害</button>


</body>

</html>


批改老师:天蓬老师批改时间:2019-02-12 12:37:40
老师总结:jQuery的DOM操作功能非常强大, 结合 实际案例,体会会更深些

发布手记

热门词条