JQuery入门——用one()方法绑定事件
2013-02-02 22:13
645 查看
1、one()方法功能是为所选的元素绑定一个仅触发一次的处理函数,其调用的语法格式为:one(type, [data], fn)
其中参数type为事件类型,即需要触发什么类型的事件;参数data为可选参数,表示作为event.data属性值传递给事件对象的额外数据对象;fn为绑定事件时所要触发的函数。
2、示例代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>其他事件</title>
<script type="text/javascript" src="jquery-1.8.3.min.js"></script>
<script type="text/javascript">
$(function(){
$("#button").bind("click",function(){
$("#button").attr("value","14797710665");
});
})
</script>
</head>
<body>
<div>
<input id="button" type="button" value="查看联系方式" class="btn"/>
</div>
</body>
</html>
3、效果图预览:
点击后:
再点击无反应
其中参数type为事件类型,即需要触发什么类型的事件;参数data为可选参数,表示作为event.data属性值传递给事件对象的额外数据对象;fn为绑定事件时所要触发的函数。
2、示例代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>其他事件</title>
<script type="text/javascript" src="jquery-1.8.3.min.js"></script>
<script type="text/javascript">
$(function(){
$("#button").bind("click",function(){
$("#button").attr("value","14797710665");
});
})
</script>
</head>
<body>
<div>
<input id="button" type="button" value="查看联系方式" class="btn"/>
</div>
</body>
</html>
3、效果图预览:
点击后:
再点击无反应
相关文章推荐
- JQuery入门――用bind方法绑定事件处理函数应用介绍
- JQuery入门――用bind方法绑定事件处理函数应用介绍
- JQuery入门――移除绑定事件unbind方法概述及应用
- 解析jQuery的三种bind/One/Live事件绑定使用方法
- jQuery的三种bind/One/Live/On事件绑定使用方法
- 【JQuery】使用one()方法绑定元素的一次性事件
- JQuery入门――用one()方法绑定事件处理函数(仅触发一次)
- JQuery入门――用one()方法绑定事件处理函数(仅触发一次)
- 浅谈jQuery代码优化之事件委托(事件绑定)——bind()|live()|delegate()|on()|off()|one()方法
- jQuery的三种bind/One/Live事件绑定使用方法
- jquery的on、off、one、bind、delegate、live、die绑定事件方法研究
- jQuery bind/One/live三种绑定事件方法的区别
- 【jQuery】使用one()方法绑定元素的一次性事件
- jQuery的三种bind/One/Live事件绑定使用方法
- JQuery入门——用unbind方法移除绑定事件
- jQuery绑定事件方法及区别(bind,click,on,live,one)
- JQuery入门——用bind方法绑定事件
- jQuery的三种bind/One/Live事件绑定使用方法
- jQuery的三种bind/One/Live/On事件绑定使用方法