4

I am new to jQuery and such kind of js frameworks. Till now I used to do like this

<div onclick="function()"></div>

But in jQuery we get the element and add the event there. How can I detect all events added on a div?

I have a div whose height is set to the remaining height. Then I cant find appropriate css for that. I strongly believe that it has been done from javascript. I cant find relavant code any where. I dont know how to debug this.

Any help is highly appreciated.

herry
  • 1,708
  • 3
  • 17
  • 30
Krishna Chaitanya
  • 2,533
  • 4
  • 40
  • 74
  • try changing some option by inspect that element sometime element inherit some behavior or if it shows inline height it may be from js – Sahil Popli Dec 27 '13 at 13:54
  • 1
    You can change the `height` of that `div` irrelevant of what js did , unless and until you have any selector for that div – Bharath R Dec 27 '13 at 13:54
  • Why not just debug using Firebug for firefox. Its a handy debugging tool – Orville Patterson Dec 27 '13 at 13:56
  • try this http://www.sprymedia.co.uk/article/Visual+Event – Majid Laissi Dec 27 '13 at 13:57
  • don't believe,`Inspect`. Most modern browsers have inbuilt dom debugging and inspecting tools. Try chrome's or FF's 'Inspect Element'. Because, even if you detect all the events subscribed on a div, what's the point, how would you evaluate which one's doing what? – Manish Mishra Dec 27 '13 at 13:59
  • It was not done via java script. The element is positioned absolute, then they added these properties `top: 45px; right: 0px; bottom: 0px; right: 0px;` That is how the div occupied entire available height. I never knew this trick/solution. – Krishna Chaitanya Dec 27 '13 at 14:08
  • As above use a debugger such as firebug and find the "break on next" feature. http://www.softwareishard.com/blog/firebug/firebug-15-break-on-next/ – Captain John Dec 27 '13 at 14:09

1 Answers1

4

To answer your question you can use:

jQuery._data( elem, "events" );

This will become an object of all events attached to the selected element.

enter image description here

This will return undefined when no event is attached to the element.

Note that this should be a single element, so for a class you should use:

$._data($('.class')[0], "events")

Which only select the first element with that class, instead of all the elements with that class.

jsFiddle


Source: jQuery find events handlers registered with an object

Community
  • 1
  • 1
nkmol
  • 8,025
  • 3
  • 30
  • 51