AI写作智能体 自主规划任务,支持联网查询和网页读取,多模态高效创作各类分析报告、商业计划、营销方案、教学内容等。 广告
[TOC] ## .off() 移除一个事件处理函数 ### 语法 ``` .off( events [, selector ] [, handler(eventObject) ] ) ``` ### 示例 #### 移除所有事件 ``` $("p").off() ``` #### 移除所有段落上的代理事件 ``` $("p").off( "click", "**" ) ``` #### 仅移除先前绑定的事件处理函数 ``` var foo = function () { // code to handle some kind of event }; // ... now foo will be called when paragraphs are clicked ... $("body").on("click", "p", foo); // ... foo will no longer be called. $("body").off("click", "p", foo); ``` #### 通过指定名字空间,解除绑定表单上所有的代理事件 ``` var validate = function () { // code to validate form entries }; // delegate events under the ".validator" namespace $("form").on("click.validator", "button", validate); $("form").on("keypress.validator", "input[type='text']", validate); // remove event handlers in the ".validator" namespace $("form").off(".validator"); ```