abstract:<!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>Document</title>
<script src="static/js/jquery-3.3.1.min.js"></script>
<style>
div{width:500px;height:500px;background: red;}
</style>
</head>
<body>
<script>
/*
/* $(selector).hover(function () {
// over鼠標(biāo)移上時觸發(fā)的函數(shù)
}, function () {
// out鼠標(biāo)移出時觸發(fā)的函數(shù)
}
);
$("div").toggle();//如果元素是可見的就切換為隱藏,否則相反
*/
$(document).ready(function () {
$("div").hover(function () {
// over
$("div").css("background", "pink");
}, function () {
// out
$("div").css("background", "red");
}
);
$("button").click(function (e) {
$("div").toggle();
});
});
</script>
<div></div>
<button>點擊</button>
</body>
</html>
Correcting teacher:天蓬老師Correction time:2019-01-21 17:56:31
Teacher's summary:$("div").toggle(), jQuery中的自動切換非常有意思, 用原生來實現(xiàn)非常的麻煩, 這也是jQuery中的一個特色, 很多動畫特效都是基于它完成的