<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>JQ点击事件的几种方法</title>
<style type="text/css">
.box{
width: 200px;
height: 200px;
background: red;
}
</style>
</head>
<body>
<div class="box" onclick="clickTap()"></div>
<script src="jquery-1.12.4.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
//第一种
$(".box").click(function(){
alert('第一种方法:$(".box").click(function(){})')
})
//第二种
$(".box").on("click",function(){
alert('第二种方法:$(".box").on("click",function(){})')
})
//第三种
$(document).on("click",".box",function(){
alert('第三种方法:$(document).on("click",".box",function(){})')
})
//第四种
function clickTap (){
alert('第四种方法:使用<οnclick="">触发函数 clickTap')
}
</script>
</body>
</html>