Reputation: 131
I am trying to animate my php gallery function, using jQuery functions. thmb_animation
function has to enlarge image in new location with mouseenter
function. When debugging the script i get TypeError. I have tried using jQuery.noConflict()
because googling usually refered to it, but it didnt do the job, so i ended up here.
$(function thumb_animation() {
var thumb = $('.st_thumb img');
var img = $('#bigImg');
var h = $(window).height();
thumb.on('mouseenter',function (e) <---- Here comes TypError
{
var thumbSource = e.target.src;
img.attr('src',thumbSource);
console.log(e);
img.show("fade", 2000);
img.animate({height:'60%',width:'66%'}, {queue: false});
});
thumb.mouseleave(function() {
img.animate({height:'0%', width:'0%'}, {queue: false});
});
});
HTML part :
<div class='wrap'>
<ul id="st_nav" class="st_navigation">
<li class="album">
<div class="st_wrapper st_thumbs_wrapper">
<div class="st_thumbs">
<?php showGallery(); ?>
</div>
</div>
</li>
</ul>
<div class='gallery'>
<img id='bigImg' src='images/album/thumbs/2.jpeg'>
</div>
Entire error message :
Uncaught TypeError: undefined is not a functionscripts.js:21 thumb_animationjquery.min.js:26 c.extend.readyjquery.min.js:33 L
Solution for the error message :
I was using older version of jQuery. But the image still doesnt show show in new location.
Upvotes: 1
Views: 1052
Reputation: 337550
on
was added to jQuery in version 1.7. I'm guessing you have an older version and need to upgrade. I would suggest 1.11
if you need to support < IE9, other wise 2.x
.
Upvotes: 3