代码之家  ›  专栏  ›  技术社区  ›  Samuel Meacham

如何判断哪些事件绑定到对象?

  •  0
  • Samuel Meacham  · 技术社区  · 15 年前

    我正在使用jqGrid( http://www.trirand.com/blog/

    我想取消绑定()任何允许调整列大小的操作,可能是在mouseover上,但我不知道如何确定对象当前有哪些回调。

    1 回复  |  直到 15 年前
        1
  •  4
  •   Community CDub    8 年前
    $('body').click(function(){ alert('test' )})
    
    var foo = $.data( $('body').get(0), 'events' ).click
    // you can query $.data( object, 'events' ) and get an object back, then see what events are attached to it.
    
    $.each( foo, function(i,o) {
        alert(i) // guid of the event
        alert(o) // the function definition of the event handler
    });
    

    抄袭我以前的答案@ jQuery check if event exists on element

    只要采用它来适应你的选择