I know I need to use a callback so that html()
doesn't happen until after fadeOut()
, but inside the fadeOut()
callback I don't have access to $(this)
from .hover
.
我知道我需要使用回调,以便html()直到fadeOut()之后才会发生,但在fadeOut()回调中我无法访问.hover中的$(this)。
I tried passing the selection using var point
, but it's not working.
我尝试使用var point传递选择,但它不起作用。
if(!$.browser.msie) {
points = $("div.point");
} else {
points = $("div.flash");
}
Problem Area:
$(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>
2 个解决方案
#1
Don't use point as a parameter to your callback for fadeOut. It will hide the point variable you "captured" earlier:
不要将point用作fadeOut回调的参数。它将隐藏您之前“捕获”的点变量:
$(points).hover(
function () {
var point = $(this);
$('#features_key').fadeOut('normal', function() {
$('#features_key').html(point.next('.info').clone()).fadeIn('normal');
});
},
function () {
}
);
#2
by putting point as a parameter in the callback function, you are resetting it's value inside that function.
通过将point作为参数放在回调函数中,您将在该函数内重置它的值。
#1
Don't use point as a parameter to your callback for fadeOut. It will hide the point variable you "captured" earlier:
不要将point用作fadeOut回调的参数。它将隐藏您之前“捕获”的点变量:
$(points).hover(
function () {
var point = $(this);
$('#features_key').fadeOut('normal', function() {
$('#features_key').html(point.next('.info').clone()).fadeIn('normal');
});
},
function () {
}
);
#2
by putting point as a parameter in the callback function, you are resetting it's value inside that function.
通过将point作为参数放在回调函数中,您将在该函数内重置它的值。