我正在尝试使用jQuery函数动画化我的php gallery函数。thmb_animation
功能必须通过mouseenter
功能在新位置放大图像。当调试脚本时,我得到TypeError。我尝试使用jQuery.noConflict()
Google搜寻是因为通常使用谷歌搜索来指代它,但是它没有完成任务,所以我在这里结束了。
$(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部分:
<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>
整个错误消息:
Uncaught TypeError: undefined is not a functionscripts.js:21 thumb_animationjquery.min.js:26 c.extend.readyjquery.min.js:33 L
错误消息的解决方案:
我正在使用旧版本的jQuery。但是图像仍未在新位置显示。
on
已在1.7版中添加到jQuery。我猜您有一个较旧的版本,需要升级。我建议1.11
您是否需要支持<IE9,否则2.x
。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句