jQuery .hover仅在注释div崩溃时

时间:2013-09-23 20:28:14

标签: jquery jquery-hover

我刚刚开始使用jQuery,需要一些帮助。

我在固定div上有我的评论框,只要用户不在页面底部,它就会折叠。当用户向下滚动时,评论框会随着评论一起缓慢显示。

我现在想要实现的是,只要评论框被折叠,我就想对它应用.hover效果。因此,当用户将其悬停时,div的大小会增加。

这是我到目前为止所做的:

var secondary = jQuery(".comments-holder");

var magicFooter = function(){
    var scrollBottom = jQuery(window).scrollTop() + jQuery(window).height();
    var maxHeight =  jQuery("#disqus_thread").height(); 
    jQuery("#colophon").css("height", maxHeight);  
    var mediumHeight = 120;
    var minHeight = 60;

    secondary.height(maxHeight - (jQuery(document).height() - scrollBottom));

    if (secondary.height() <= minHeight) {

            secondary.css("height",minHeight);
            secondary.hover(function(){
                    jQuery(this).css("height",mediumHeight);
            },
            function(){
                jQuery(this).css("height",minHeight);
            });

        } 

}; 
magicFooter();

jQuery(window).scroll(function() {
    magicFooter();
});

.hover效果无法正常工作。我想只在div处于minHeight时应用它。

0 个答案:

没有答案