首页 > 其他分享 >JQ 移除事件

JQ 移除事件

时间:2023-06-26 20:06:47浏览次数:35  
标签:function bind 绑定 JQ 事件 移除 test click append


demo.html

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<style type="text/css">
*{margin:0;padding:0;}	
body { font-size: 13px; line-height: 130%; padding: 60px; }
p {width:200px;background:#888;color:white;height:16px;}
</style>
<script src="js/jquery-1.10.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function(){
	$('#btn').bind("click", function(){
		$('#test').append("<p>我的绑定函数1</p>");
	}).bind("click", function(){
		$('#test').append("<p>我的绑定函数2</p>");
	}).bind("click", function(){
		$('#test').append("<p>我的绑定函数3</p>");
	});
})
</script>
</head>
<body>
<button id="btn">点击我</button>
<div id="test"></div>
</body>
</html>

效果图:

JQ 移除事件_javascript


 

demo2.html

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<style type="text/css">
* {
	margin: 0;
	padding: 0;
}
body {
	font-size: 13px;
	line-height: 130%;
	padding: 60px;
}
p {
	width: 200px;
	background: #888;
	color: white;
	height: 16px;
}
</style>
<script src="js/jquery-1.10.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function(){
	$('#btn').bind("click", function(){
		$('#test').append("<p>我的绑定函数1</p>");
	}).bind("click", function(){
		$('#test').append("<p>我的绑定函数2</p>");
	}).bind("click", function(){
		$('#test').append("<p>我的绑定函数3</p>");
	});
	$('#delAll').click(function(){
		$('#btn').unbind("click");
	});
})
</script>
</head>
<body>
<button id="btn">点击我</button>
<div id="test"></div>
<button id="delAll">删除所有事件</button>
</body>
</html>

效果图:

JQ 移除事件_javascript_02


 

demo3.html

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<style type="text/css">
* {
	margin: 0;
	padding: 0;
}
body {
	font-size: 13px;
	line-height: 130%;
	padding: 60px;
}
p {
	width: 200px;
	background: #888;
	color: white;
	height: 16px;
}
</style>
<script src="js/jquery-1.10.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function(){
	$('#btn').bind("click", myFun1 = function(){
		$('#test').append("<p>我的绑定函数1</p>");
	}).bind("click", myFun2 = function(){
		$('#test').append("<p>我的绑定函数2</p>");
	}).bind("click", myFun3 = function(){
		$('#test').append("<p>我的绑定函数3</p>");
	});
	$('#delTwo').click(function(){
		$('#btn').unbind("click",myFun2);
	});
})
</script>
</head>
<body>
<button id="btn">点击我</button>
<div id="test"></div>
<button id="delTwo">删除第二个事件</button>
</body>
</html>

效果图:

JQ 移除事件_ViewUI_03


 

demo4.html

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<style type="text/css">
* {
	margin: 0;
	padding: 0;
}
body {
	font-size: 13px;
	line-height: 130%;
	padding: 60px;
}
p {
	width: 200px;
	background: #888;
	color: white;
	height: 16px;
}
</style>
<script src="js/jquery-1.10.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function(){
	$('#btn').one("click", function(){
		$('#test').append("<p>我的绑定函数1</p>");
	}).one("click", function(){
		$('#test').append("<p>我的绑定函数2</p>");
	}).one("click", function(){
		$('#test').append("<p>我的绑定函数3</p>");
	});
})
</script>
</head>
<body>
<button id="btn">点击我</button>
<div id="test"></div>
</body>
</html>

效果图:

JQ 移除事件_javascript_04


 

 

 

标签:function,bind,绑定,JQ,事件,移除,test,click,append
From: https://blog.51cto.com/u_16171388/6557260

相关文章

  • JQ 自动加载页面
    demo.html<listyle="opacity:0;-moz-opacity:0;filter:alpha(opacity=0);"><p>---------------</p></li><listyle="opacity:0;-moz-opacity:0;filter:alpha(opacity=0);"><p>阅谁问君诵,水落清香浮</p></li>......
  • JQ 其它的点击事件用法
    demo.html<html><head><title></title><metahttp-equiv="Content-Type"content="text/html;charset=utf-8"/><style>.over{ color:red; background:#888;}</style><scriptsrc="js/j......
  • JQ 复选框全选反选
    <!DOCTYPE><html><head><metahttp-equiv="Content-Type"content="text/html;charset=utf-8"/><title></title><scriptsrc="js/jquery-1.10.1.min.js"type="text/javascript">&......
  • JQ 多行文本框高度变化
    <html><head><metahttp-equiv="Content-Type"content="text/html;charset=utf-8"/><title>文本框高度变化</title><styletype="text/css">*{ margin:0; padding:0; font:normal12px/17pxArial......
  • JQ 下拉框左右选择
    <html><head><metahttp-equiv="Content-Type"content="text/html;charset=utf-8"/><title></title><styletype="text/css">*{ margin:0; padding:0;}div.centent{ float:left; text-......
  • JQ 表格展开伸缩
    style.csstable{border:0;border-collapse:collapse;}td{font:normal12px/17pxArial;padding:2px;width:100px;}th{font:bold12px/17pxArial;text-align:left;padding:4px;border-bottom:1pxsolid#333;width:100px;}.parent{background:#FFF38F;cursor:point......
  • JQ 瀑布流
    demo.css*{ padding:0; margin:0;}.wrap{ position:relative;}.box{ position:absolute; left:0; top:0; width:250px;}.boximg{ width:250px;} demo.js$(function(){ $('img').load(function(){ varbox=$('.box'); var......
  • JQ 可展开折叠的导航
    <!doctypehtml><htmllang="en"><head><metacharset="UTF-8"><title>Document</title><style>*{padding:0;margin:0;}li{list-style-type:none;}body{margin:50px;font-family:\5FAE\8F6......
  • JQ 拖拽
    <!doctypehtml><htmllang="en"><head><metacharset="UTF-8"><title>拖拽</title><style>*{ padding:0; margin:0;}div{ width:100px; height:100px; background:#f00; cursor:pointer; ......
  • JQ 放大镜
    zoom.css*{ padding:0; margin:0;}li{ list-style-type:none;}.zoom{ margin:50px; position:relative;}.zoomMiddle{ border:1pxsolid#ccc; width:300px; height:300px; margin-bottom:3px; position:relative;}.zoomMiddleimg{ width:300p......