我试图删除一个附加的元素后,我已经隐藏了鼠标出来的元素。我在.hover回调中的回调做错了什么?
// START OF $(document).ready(function() {
$(document).ready(function ()
$('.custom-right-boxes a').hover(function () {
$(this).append('<div class="click-here"><b>Click</b><span>Here</span></div>');
$('.click-here').stop().animate({
width: '88px',
height: '58px',
marginLeft: '-44px',
marginTop: '-40px'
}, {
duration: 300
});
}, function () {
$('.click-here').stop().animate({
width: '0px',
height: '0px',
marginLeft: '-0px',
marginTop: '-0px'
}, {
duration: 300
}),
function () {
$('.click-here').remove();
};
});
// END OF $(document).ready(function() {
});发布于 2012-11-02 15:08:08
伙计们,成功了!感谢所有帮助我们的人。基本上,Nelson告诉我的这一点很关键,所以感谢这一点,我也不得不改变:
,{时长: 300 }
简单地说:
,300
然后回调起作用了:-)这是最终的代码(在我做额外的修改之前):
// START OF $(document).ready(function() {
$(document).ready(function () {
$('.custom-right-boxes a').hover(function () {
$(this).append('<div class="click-here"><b>Click</b><span>Here</span></div>');
$('.click-here').stop().animate({
width: '88px',
height: '58px',
marginLeft: '-44px',
marginTop: '-40px'
}, 300);
}, function () {
$('.click-here').stop().animate({
width: '0px',
height: '0px',
marginLeft: '-0px',
marginTop: '-0px'
}, 300, function () {
$('.click-here').remove();
});
});
// END OF $(document).ready(function() {
});发布于 2012-11-02 03:01:54
在您的代码中修复以下内容:
}, {
duration: 300
}), //--> REMOVE THIS parens
function () {
$('.click-here').remove();
}; //ADD A PARENS HERE, like });因为您错误地将第三个参数传递给了animate(),即回调函数。做了上面提到的更改,并尝试一下。
这将是更正后的版本:
// START OF $(document).ready(function() {
$(document).ready(function (){
$('.custom-right-boxes a').hover(function () {
$(this).append('<div class="click-here"><b>Click</b><span>Here</span></div>');
$('.click-here').stop().animate({
width: '88px',
height: '58px',
marginLeft: '-44px',
marginTop: '-40px'
}, {
duration: 300
});
}, function () {
$('.click-here').stop().animate({
width: '0px',
height: '0px',
marginLeft: '-0px',
marginTop: '-0px'
}, {
duration: 300
},
function () {
$('.click-here').remove();
});
});
// END OF $(document).ready(function() {
});https://stackoverflow.com/questions/13183721
复制相似问题