1

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)
function()

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

llamerr
  • 2,997
  • 4
  • 29
  • 40

3 Answers3

2

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.

Community
  • 1
  • 1
SBUJOLD
  • 1,463
  • 2
  • 11
  • 21
1

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

IonuČ› G. Stan
  • 176,118
  • 18
  • 189
  • 202
1

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);})"

llamerr
  • 2,997
  • 4
  • 29
  • 40