.undelegate()返回: jQuery标记弃用版本: 3.0
描述: 删除当前选择器匹配的所有元素的事件处理程序,根据一组特定根元素的集合。
- 
添加的版本: 1.4.2.undelegate()
- This method does not accept any arguments.
 
 - 
添加的版本: 1.4.2.undelegate( selector, eventType )
 - 
添加的版本: 1.4.2.undelegate( selector, eventType, handler(eventObject) )
 - 
添加的版本: 1.4.3.undelegate( selector, events )
- 
selector类型: String选择器字符串,用于过滤器触发事件的元素。
 - 
events类型: PlainObject一个或多个事件类型和以前绑定的函数组成的一个对象,用来以解除他们(处理程序)。
 
 - 
 - 
添加的版本: 1.6.undelegate( namespace )
- 
namespace类型: String一个字符串,其中包含一个命名空间,以解除所有事件。
 
 - 
 
在jQuery 3.0中,.undelegate()已被标记为弃用。从jQuery 1.7开始,它已经被.off()方法取代。所以我们不建议使用该方法。
.undelegate是用来移除使用.delegate()的方式已经绑定的事件处理程序。(注:从 jQuery 1.7 开始,a href="/jqapi-1.9/on">.on() 和 .off()方法是最好的元素上附加和移除事件处理程序的方法。)
例子:
Example: 可以绑定和取消绑定事件的彩色按钮。
| 
          
             1 
          
            2 
          
            3 
          
            4 
          
            5 
          
            6 
          
            7 
          
            8 
          
            9 
          
            10 
          
            11 
          
            12 
          
            13 
          
            14 
          
            15 
          
            16 
          
            17 
          
            18 
          
            19 
          
            20 
          
            21 
          
            22 
          
            23 
          
            24 
          
            25 
          
            26 
          
            27 
          
            28 
          
            29 
          
            30 
          
         | 
        
          
  | 
      
Demo:
Example: 解除绑定的所有段落都从委托的事件:
| 
          
             1 
          
         | 
        
          
  | 
      
Example: 解除绑定的所有段落的所有委托点击事件:
| 
          
             1 
          
         | 
        
          
  | 
      
Example: 为了undelegate只是一个以前绑定的处理程序,通过在作为第三个参数的函数:
| 
          
             1 
          
            2 
          
            3 
          
            4 
          
            5 
          
            6 
          
            7 
          
            8 
          
            9 
          
            10 
          
         | 
        
          
  | 
      
Example: 为了拆散他们的命名空间的所有委托事件:
| 
          
             1 
          
            2 
          
            3 
          
            4 
          
            5 
          
            6 
          
            7 
          
            8 
          
            9 
          
            10 
          
            11 
          
            12 
          
         | 
        
          
  |