您的位置:首页 > Web前端 > JQuery

jQuery的bind()的三种使用方式事件监听

2016-06-08 10:50 393 查看
bind的三种使用方法
1:直接的加方法名和 函数(可以是匿名函数也可以是一般函数)
2:一次性的添加多个事件名,使用同一个处理函数
3:添加对个函数,每个函数一个处理函数。
</pre><pre name="code" class="html">移除事件监听 可以直接加事件名
</pre><pre name="code" class="html">
</pre><pre name="code" class="html"><!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script  src="js/jquery.js">

</script>
</head>
<body>
<input type="button" value="按钮" />
</body>
<script type="text/javascript">
alert($("input[value=按钮]")[0].value)

$("input[value=按钮]").bind('click',function(){
alert("fujichao")
})
//		$('input').bind('mouseover mouseout',function(){
//			alert("fuji")
//		})

//		$('input').bind({
//			mouseover:function(){
//				alert('fu')
//			},
//			mouseout:function(){
//				alert('2')
//			}
//		})

$('input').bind('click',function(){
alert("fuji ")
})
$('input').bind({

})
<span style="white-space:pre">		</span><p style="margin-top: 0px; margin-bottom: 0px; font-size: 15px; line-height: normal; font-family: Consolas; color: rgb(6, 6, 6);"><span style="white-space:pre">	</span>$(<span style="color: #289c97">'input'</span>).unbind()</p>
</script>
</html>

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: