Skip to content

Instantly share code, notes, and snippets.

@303182519
Created October 28, 2014 09:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 303182519/a6d5d8faef6a4bfa502f to your computer and use it in GitHub Desktop.
Save 303182519/a6d5d8faef6a4bfa502f to your computer and use it in GitHub Desktop.
一个解绑的测试
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style type="text/css">
*{
margin: 0;
padding: 0;
}
div {
width: 100px;
height: 50px;
background: #000;
margin-bottom: 20px;
cursor: pointer;
color: #fff;
}
</style>
</head>
<body>
<div id="a">a</div>
<div id="b">b</div>
<div id="e">e</div>
<div id="c">c</div>
</body>
<script type="text/javascript" src="http://sz.duowan.com/s/jquery/jquery.js"></script>
<script type="text/javascript">
$(function(){
function a(){
alert("a");
}
function b(){
alert("b");
}
function e(){
alert("e");
}
/*$("body").delegate("#a","click.a",a);
$("body").delegate("#b","click.b",b);
$("#c").on("click",function(){
$("body").unbind('.a');
})*/
$("body").on("click.a","#a",a);
$("body").on("click.a","#e",e);
$("body").on("click","#b",b);
$("#c").on("click",function(){
$("body").off('.a');
})
})
</script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment