abstrait:<!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)移上時(shí)觸發(fā)的函數(shù)
}, function () {
// out鼠標(biāo)移出時(shí)觸發(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>點(diǎn)擊</button>
</body>
</html>
Professeur correcteur:天蓬老師Temps de correction:2019-01-21 17:56:31
Résumé du professeur:$("div").toggle(), jQuery中的自動(dòng)切換非常有意思, 用原生來實(shí)現(xiàn)非常的麻煩, 這也是jQuery中的一個(gè)特色, 很多動(dòng)畫特效都是基于它完成的