【发布时间】:2014-11-19 19:49:29
【问题描述】:
jQuery(window).scroll(function(){
if (jQuery(this).scrollTop() > 100) {
jQuery('#topcontrol').css({bottom:"15px"});
} else {
jQuery('#topcontrol').css({bottom:"-100px"});
}
});
jQuery('#topcontrol').click(function(){
jQuery('html, body').animate({scrollTop: '0px'}, 800);
console.log('works');
});
什么都没有发生。控制台中没有显示错误。无论是什么事件——单击、悬停等——它们只有在我将它们应用于“html”标签时才有效。代码的第一部分完美运行,我的意思是 .css。
这是什么魔法?
【问题讨论】:
标签: javascript jquery events javascript-events event-handling