我该怎么做才能让小鼠离开呢?' mouseleave'函数仅在div高度为15%时执行?

时间:2017-04-11 21:38:14

标签: jquery html css

我对Jquery比较新,所以请原谅我的无能,但我有这个功能:

$('#contact').mouseleave(function () {

    $('#contact').animate({
        borderTopLeftRadius: "0%",
        borderTopRightRadius: "0%"
    }, 50);
    $('#contact').animate({
        height: "10%"
    }, 50);
    $('#home').animate({
        height: "80%"
    }, 50);
    $('#logo').animate({
        height: "45%"
    }, 50);
});

但我只想在' #contact'身高是15%,我知道' .height()'只读取像素,因为15%可能是任何数量的像素,我需要帮助编写if语句

1 个答案:

答案 0 :(得分:1)

var height = parseInt($("#contact").css("height"));

比你可以转换成百分比:

Can jquery return height of an element as a percentage?

然后在动画之前放置if语句