如何查看关联的单击功能代码

时间:2010-04-30 13:54:52

标签: javascript jquery firebug click

例如,我将以下函数与某个元素相关联

$('table#users tbody tr:first #save').click(function(){
    $(this).closest('tr').remove();
});

现在,如果我不知道这个函数存储在哪里,有没有办法查看与click()代码相关联?在上面的例子中,我想要一种在firebug或其他方式中查看的方法

$(this).closest('tr').remove();

如果我在控制台中写作,我会得到一个指向dom检查员的链接

>>> ($('table#users tbody tr:first #save').click)
function()

但是链接是针对jquery库的,而不是我想要的代码。

3 个答案:

答案 0 :(得分:2)

我认为这会回答你的问题How to find event listeners on a DOM node when debugging or from the JavaScript code?

您在编写代码时获得DOM检查器链接的原因是调用$(selector).click实际上会引发单击事件并返回结果集。

答案 1 :(得分:1)

答案 2 :(得分:1)

javascript中还有一个Function对象的默认方法 - toSource

http://www.devguru.com/technologies/ecmascript/quickref/function_object.html

示例:

  
    
      

>>> $( 'JQ-runCode')。click.toSource()

             

“(function(d){return d?this.bind(b,d):this.trigger(b);})”