1

Is there any way to check if an element already has an action, triggered by jQuery .hover function?

abstractmind
  • 107
  • 10
  • 2
    There is no documented way to do it that doesn't use internal methods that are subject to change from version to version. – Kevin B Mar 25 '13 at 14:17
  • There's no easy way to do that, but you can check `$._data( elem, "events" );` and see if mouseenter/leave has been bound. – adeneo Mar 25 '13 at 14:17
  • check this http://stackoverflow.com/questions/1236067/test-if-event-handler-is-bound-to-an-element-in-jquery – ebram khalil Mar 25 '13 at 14:19

2 Answers2

1

You can check it by checking element.data('events')['eventName']

In case of hover, it will be:

var hasHover = x.data('events')['mouseover'] && x.data('events')['mouseout'];

In jQuery 1.8 and later, you must access it using $._data as mentioned in this answer

i.e.

var events = $._data(obj[0], "events");
var hasHover = events['mouseover'] && events['mouseout'];
Community
  • 1
  • 1
techfoobar
  • 65,616
  • 14
  • 114
  • 135
0

have a look at the filter on the selector

$('.result').each(function(){
$(this).hover(function() {
$(this).filter(':not(:animated)').animate({
'height':'110px',
},160);
},function(){$(this).animate({'height':'38px'},80);});
});
john Smith
  • 17,409
  • 11
  • 76
  • 117