<!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>操作样式的相关方法</title>
<style>
</style>
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script>
$(function () {
/*
jQuery中有两种事件绑定方式
1,eventName(fn)
编码效率略高,部分的事件jquery没有实现
2,on(eventName,fn)
编码效率低些,所有事件都可以实现
注意点:可以添加多个相同或不同类型事件,并且不会覆盖
*/
$("button").click(function(){
alert("hello");
})
$("button").on("click",function(){
alert("hello2")
})
$("button").mouseleave(function(){
alert("hello mouseLeave")
})
$("button").mouseenter(function(){
alert("hello mouseenter")
})
})
</script>
</head>
<body>
<button>事件</button>
</body>
</html>
jQuery中绑定事件的两个方法
最新推荐文章于 2024-03-20 08:53:45 发布