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">
<script type="text/javascript" src="jquery-3.3.1.min.js">
</script>
<style>
.box{
width:100px;
height: 100px;
background: red;
}
.box1{
border:10px solid green;
}
</style>
<title>测试文件</title>
</head>
<body>
<div class="box"></div>
<script>
$(document).ready(function(){
// $('div').hover(
// function(){
// $(this).css('background','green');
// },
// function(){
// $(this).css('background','yellow');
// })
$('div').click(function(){
$(this).toggle().css('background','red');
})
})
</script>
</body>
</html>
Correcting teacher:天蓬老师Correction time:2019-02-03 15:14:57
Teacher's summary:$(this).toggle().css('background','red');样式切换, 这么简单的一行代码,原生需要大约二十行才可, jQuery确实简单