码迷,mamicode.com
首页 > Web开发 > 详细

Jquery 移除 html中绑定的onClick事件

时间:2016-11-01 14:09:23      阅读:483      评论:0      收藏:0      [点我收藏+]

标签:tle   bsp   null   school   click   target   question   title   com   

  HTML绑定示例

<button class="edit" onClick="showTurnEdit(this)">编辑</button>

  

  需求:

  在点击触发submit方法后,触发移除掉 .edit 中的onClick事件;

 

  解决方案:

 

  1.失败方案:

$(".edit").removeAttr("onclick");//网上有些资料说jquery1.6+可以使用,但我试过不可以

 

  2.成功方案:

//亲测可用
$(".edit").prop("onclick",null).off("click");//jQuery1.7+

$(".edit").attr(‘onclick‘,‘‘).unbind(‘click‘);//jQuery-1.7

 

 

参考资料:

1. http://www.w3schools.com/jquery/event_off.asp

2.http://stackoverflow.com/questions/1687790/how-to-remove-onclick-with-jquery

Jquery 移除 html中绑定的onClick事件

标签:tle   bsp   null   school   click   target   question   title   com   

原文地址:http://www.cnblogs.com/springlight/p/6018994.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!