0

I have 2 divs A & B. div A has a position absolute to the relative wrapper parent of both divs. div A is positioned above div B from getting the position of div B - offset 0 -50.

now the hover is working well in the first hover(div A left: 561px) but in the second hover it goes left: 1022px. and the third time it's still 1022px. even if on the hover off function I reset the left to 0.

$(".longlist").hover(function () {
    $(this).next("div.hoverwrapper").position({
        "my": "center top",
        "at": "center top",
        "offset": "0 -50",
        "of": $(this)
    });
    $(this).next("div.hoverwrapper").css('z-index', '100');
    $(this).next("div.hoverwrapper").animate({
        opacity: "show",
        top: "-75"
    }, "slow");
}, function () {
    $(this).next("div.hoverwrapper").css('z-index', '-1');
    $(this).next("div.hoverwrapper").animate({
        opacity: "hide",
        top: "-10"
    }, "fast");
    $(this).next("div.hoverwrapper").css({
        "top": "0",
        "left": "0"
    });
});



I don't understand why is it happening...

4

1 回答 1

1
$(".longlist").hover(function () {
    $(this).next("div.hoverwrapper").position({
        "my": "center top",
        "at": "center top",
        "offset": "0 -50px",
        "of": $(this)
    });
    $(this).next("div.hoverwrapper").css('z-index', '100');
    $(this).next("div.hoverwrapper").animate({
        opacity: 1,
        top: -75
    }, "slow");
}, function () {
    $(this).next("div.hoverwrapper").css('z-index', '-1');
    $(this).next("div.hoverwrapper").animate({
        opacity: 0,
        top: -10
    }, "fast");
    $(this).next("div.hoverwrapper").css({
        "top": 0,
        "left": 0
    });
});

你不必改变不透明度的东西,但如果你把位置作为字符串,它们必须有“px”(0除外),所以顶部:“-75”不是有效数量,它必须是“-75px”或只是数字-75。

于 2012-06-28T14:49:35.717 回答