2

I am working on a very complex website and i have a piece of HTML on the page inside which no button is clickable. I think the click event gets caught somewhere so that the click handlers of the buttons do not fire.

How can I find out where those click events gets caught?

Paul D. Waite
  • 96,640
  • 56
  • 199
  • 270
Thariama
  • 50,002
  • 13
  • 138
  • 166

3 Answers3

4

Add a click event listener to the document, and see what's catching the event:

document.addEventListener('click',function(e){
    console.log(e.target);
})
Cerbrus
  • 70,800
  • 18
  • 132
  • 147
  • No, this is not what i am looking for. This way i do get the clicked html element, but this doen't help me find the piece of code where the click events propagation gets stopped. – Thariama Jan 07 '13 at 12:34
  • @Thariama: In that case, it might be an idea to have a look at [this SO question](http://stackoverflow.com/questions/446892/how-to-find-event-listeners-on-a-dom-node), and use my code to check what element you should inspect. – Cerbrus Jan 07 '13 at 12:37
  • i am using the Visul Event bookmarklet already since several months. Tried it here, but i have not been able to detect the desired click event handler – Thariama Jan 07 '13 at 12:42
  • Then my last suggestion would be to add a [breakpoint in your JavaScript](https://developers.google.com/chrome-developer-tools/docs/scripts-breakpoints), and try to see if you can find the function responsible. – Cerbrus Jan 07 '13 at 12:44
  • found out the source to my problem has been soemwhere else (there was no stopping of the propagation, but an overlying html elment that prevented the desired element to be clicked). i will accept this answer because it is the solution to the problem in case an event intercepts/stops propagation – Thariama Jan 07 '13 at 14:34
  • You could have found that by using Firebug inspect. – ATOzTOA Jan 07 '13 at 14:44
0

Just check the event.target of the click event to see where it is.

Naftali
  • 144,921
  • 39
  • 244
  • 303
  • 1
    For that, you have to add an event handler to the clicked element. The OP wants to know where to add that event handler. – 11684 Dec 21 '12 at 15:55
0

There should be a document.click() or document.live("click",...) handler somewhere in the javascript included in the page, which returns false.

ATOzTOA
  • 34,814
  • 22
  • 96
  • 117