0

I want to get the function which be defined in some event.

function clicked(){
    console.log("clicked");
}

jQuery("button").click(clicked)

I need to get the "clicked" function name or even get the whole "clicked" function.

Is there any way to get the function which defined in some event?

Kevin Chen
  • 122
  • 1
  • 9
  • 1
    This seems like an X/Y question. It may well be possible to do this, by why do you feel the need to do it? I ask as I'm certain there's a much better way. – Rory McCrossan Aug 07 '19 at 08:54
  • 1
    `jQuery._data( elem, "events" );` and then you can navigate to the `click` event and get the `clicked` function from it (but this is *really really* weird to want to do) – CertainPerformance Aug 07 '19 at 08:54
  • https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/name + https://stackoverflow.com/questions/2648293/how-to-get-the-function-name-from-within-that-function – Dominic Aug 07 '19 at 08:56
  • @Dominic that's not really the same as what the OP is asking. – Rory McCrossan Aug 07 '19 at 08:56

0 Answers0