将$(this)传递给jQuery fadeOut回调

问题描述 投票:1回答:2

[我知道我需要使用回调,以便直到html()之后才发生fadeOut(),但在fadeOut()回调中,我无法从$(this)访问.hover

我尝试使用var point传递选择,但不起作用。

if(!$.browser.msie) {
    points = $("div.point");
} else {
    points = $("div.flash");
}

问题区域

$(points).hover(
    function () {
        var point = $(this);
        $('#features_key').fadeOut('normal', function (point) {
            $('#features_key').html(point.next('.info').clone()).fadeIn('normal');
        });
    },
    function () {
    }
);

HTML

<div class="feature" id="feature0">
    <div class="point"></div>
    <div class="info"><p>Roof System</p></div>
</div>
javascript jquery function callback effects
2个回答
8
投票

不要将point作为您的fadeOut回调的参数。它将隐藏您之前“捕获”的点变量:

$(points).hover(
    function () {
            var point = $(this);

            $('#features_key').fadeOut('normal', function() {
                    $('#features_key').html(point.next('.info').clone()).fadeIn('normal');
            });
    }, 
    function () {
    }
);

0
投票

通过在回调函数中将点作为参数,您可以在该函数中重置它的值。

© www.soinside.com 2019 - 2024. All rights reserved.