0

I have an jquery element and I attach a function to it

element.on('click', function(){
    // do stuff
});

If I want to find the function that does the //do stuff, where inside the element would I find it, in order to execute it manually if needed. (element[???](); -> //does stuff)

laggingreflex
  • 32,948
  • 35
  • 141
  • 196

2 Answers2

1

if you want to reuse that function just make it a standalone function and bind it to the click event

function doStuff(e) {
    // ...
}

element.bind('click', doStuff);
fuchs777
  • 993
  • 1
  • 14
  • 30
1

I guess you mean manually triggering an event handler. Use:

element.trigger('click');
mrmoment
  • 727
  • 2
  • 10
  • 34