开发者

how to view associated click function code

For example, i associate following function with some element

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

Now, if i don't know where this function is stored, is there a way to view associated with click() code? In above example, i want a way to view that in firebug, or in another way

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

If I'm writing in console following, i'm get a link to dom inspector

>>> ($('table#users tbody tr:first #save').click)
functio开发者_运维技巧n()

but link is for jquery library, not the code i want.


I think this will answer your question How to find event listeners on a DOM node when debugging or from the JavaScript code?

The reason you get a link to the DOM inspector on the code you wrote is because calling $(selector).click will actually raise the click events and return the result set.


Try the eventbug plugin for Firebug: http://blog.getfirebug.com/2009/10/30/event-listener-view-for-firebug/


There is also default method of Function object in javascript - toSource

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

example:

>>> $('.jq-runCode').click.toSource()

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜