$.on 绑定事件时支持命名组参数,$.off 时支持根据

jquery.onoff jQuery on,off 方法扩展,增加一个参数,实现绑定事件时可以按分组命名,移除事件时可以按分组名批量删除事件 GitHub: https://github.com/aiv367/jquery.onoff Demo: https://aiv367.github.io/jquery.onoff/demo/ Author:aiv367 (大花猫花大) 说明 on,off 方法在原有方法基础上,增加了一个参数,实现以分组命名方式,绑定、移除事件 分组命名只能是数字字母下划线 更新 V1.0.0 [2019/05/24] 依赖 jQuery2.0+ 使用

<script src="jquery.js"></script> <script src="jquery.onoff.js"></script>

<script> $('#demo') .on('input', (evt)=>{ console.log('oninput1'); }, 'myevent') .on('input', (evt)=>{ console.log('oninput2'); }, 'myevent') .on('input', (evt)=>{ console.log('oninput3'); }) .on('change', (evt)=>{ console.log('onchange1'); }); //移除 myevent 分组的事件 $('#demo').off('input', 'myevent'); </script>

版权声明:

1、该文章(资料)来源于互联网公开信息,我方只是对该内容做点评,所分享的下载地址为原作者公开地址。
2、网站不提供资料下载,如需下载请到原作者页面进行下载。