注:以下所有效果都会以此结构展示
<style>
#box{
width: 300px;
height: 300px;
background-color: pink;
margin: 200px auto;
transition: 0.5s;
text-align: center;
line-height: 300px;
}
</style>
</head>
<body>
<div id="box"></div>
</body>
1. 鼠标点击效果: mousedown
当鼠标指针移动到元素上方,并按下鼠标按键时,会发生 mousedown 事件。
<script>
$(function(){
$("#box").mousedown(function(){
$(this).css("background","cyan")
$(this).html("mousedown事件发生")
})
})
</script>
2. 鼠标(指针)穿过效果:mouseenter
当鼠标指针穿过元素时,会发生 mouseenter 事件。该事件大多数时候会与mouseleave 事件一起使用。
<script>
$(function(){