所以我做了一个wordpress站点,里面有一些动画,效果很好。只有当我滚动站点时,它们才能工作,并且看起来像这样:
jQuery(document).ready(function($){
$(window).scroll( function(){
if(!isMobile) {
$('.animate_1').each( function(i){
var bottom_of_object = $(this).position().top + $(this).outerHeight();
var bottom_of_window = $(window).scrollTop() + $(window).height();
/* If the object is completely visible in the window, fade it it */
if( bottom_of_window > bottom_of_object ){
$(this).animate({opacity:'1', margin: '0 3% 0 3%'},2000, 'easeInOutQuart');
}
})
}
})
});
这可以很好地工作。现在,我想要在站点加载时创建一个我称之为".aniamte_2“的类,不需要任何滚动或单击。我是这样尝试的:
jQuery(document).ready(function($){
$('.animate_2').animate({opacity:'1', margin: '0 3% 0 3%'},2000, 'easeInOutQuart');
});
由于某种原因,它不起作用。Chrome告诉我"$“是undefiend之类的。
有人知道如何在不滚动的情况下制作动画吗?
发布于 2015-03-04 17:54:52
如果浏览器不能识别$,这很好地表明jQuery没有加载;出现这种情况有很多原因。
https://stackoverflow.com/questions/28851110
复制相似问题