mouseenter and mouseleave are not working for "jQuery Update 5.x-2.x: jQuery 1.2.x (currently 1.2.6)" on an installation of Drupal 5.19 The console throws a "mouseenter is not a function" error

Try something like this:

$('#myDiv').mouseenter(function(){
$(this).animate({
left: +='10'
}, 500, function() {
});
}).mouseleave(function(){
$(this).animate({
left: -='10'
}, 500, function() {
});
});

Installation went smoothly and we've been using this plugin without a problem until now that we needed to use these events.

Comments

sam3k’s picture

Status: Active » Needs review

Ok, so after playing around I found it possible to use mouseenter and mouseleave using jquery bind()

$('#myDiv').bind('mouseenter', function() {
$(this).animate({
left: '10'
}, 100, function() {
sidetabAnimating = false;
});
});

$('#myDiv').bind('mouseleave', function() {
$(this).animate({
left: '0'
}, 100, function() {
sidetabAnimating = false;
});
});

Still, if someone could shed some light into why I can't just use them as methods it would greatly help for future reference.

Mumonkan’s picture

i am getting weird stuff around mouseenter and mouseleave and jquery with drupal too! i am so glad you posted this cuz i thought i was going crazy.

fwiw, i cannot even get the bind() option to work. *however* at least the bind way does NOT halt my javascript, which is what was happening when i was doing $(#foo).mouseenter(). code beyond that point was simply not working. sigh.

i am not sure why this doesnt work, as the jquery docs said this was added in v1.0. and i have tried moving things inside .ready() as well. nothing works. it just silently fails. and yet it works for me on the jquery example page. i am stumped.

_rune’s picture

I believe "mouseenter is not a function" would occur when trying to run ".mouseenter()" on a non-existing element, i.e. an empty selection like $('#dont-exist').mouseenter(...".

Cheers
Rune

yongke’s picture

Hi, I used your workaround and got it to work in Drupal 6. Thanks!

nzcodarnoc’s picture

Using the bind technique in #1 worked for me.

aulnes-69-omettre@icloud.com’s picture

Works perfectly. Thanks !

codeglyph’s picture

same problem here.
#1 works. thnx

jordotech’s picture

This came in really handy for me too, had the same problem. Thanks!

sumaiyajaved’s picture

Version: 5.x-1.0 » 6.x-2.x-dev

I am using drupal 6 without jquery update and had the same issue.

Thanks sam3k, using bind() solved it. I was thinking it could be because of jquery version, but just guessing here.

markhalliwell’s picture

Issue summary: View changes
Status: Needs review » Closed (outdated)

Drupal 6 reached EOL (end-of-life) on February 24, 2016.