9

I wanted to test chrome to see if it can show me what method will be running for onclick registered event.

So I wanted to see which JS function execute shen people upvotes a question :

https://i.sstatic.net/3mbce.jpg

enter image description here

But I couldn't found the actual code.

is it possible with chrome to find which JS executes when "onclick"?

edit

I could use the console to do it with :

$.each($(".vote-up-off").data("events"), function(i, e) {  // this will work till jq 1.8
  console.log(this)
});

and here is our friend:

enter image description here

But hey ! , I want chrome to do the work :-)

1
  • Have you tried using Chrome's JavaScript CPU profiler? Commented Feb 16, 2013 at 12:37

2 Answers 2

3

One potential insight might be to enter this in your console and press return:

$('.vote a').data('events').click;

jQuery stores all of its events which are bound to an object inside of the data() object; so if you want to view a particular event binding, this is your place to look. Console will return an object. Expand handler --> <function scope> --> Closure and you can now see all of the associated JavaScript around this click event.

Sign up to request clarification or add additional context in comments.

1 Comment

Awesome, well done. Saves me having to upload a screenshot now!
2

some workarounds available U may try this bookmarklet concept Visual Event

Add bookmarklet to you browser bookmarks(enable bookmarks bar show always) and click on bookmark while on the page u want to debug

PS: it is for Jquery

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.