Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/80.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jQuery回调在.hover回调中_Jquery_Callback - Fatal编程技术网

jQuery回调在.hover回调中

jQuery回调在.hover回调中,jquery,callback,Jquery,Callback,在我将元素隐藏在鼠标外之后,我试图删除附加的元素。我对.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

在我将元素隐藏在鼠标外之后,我试图删除附加的元素。我对.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() {

});
//开始$(文档).ready(函数(){
$(文档).ready(函数()
$('.custom right Box a')。悬停(函数(){
$(this.append('ClickHere');
$('.click here').stop().animate({
宽度:“88px”,
高度:'58px',
marginLeft:“-44px”,
marginTop:“-40px”
}, {
持续时间:300
});
},函数(){
$('.click here').stop().animate({
宽度:“0px”,
高度:“0px”,
marginLeft:“-0px”,
marginTop:“-0px”
}, {
持续时间:300
}),
函数(){
$('.click here').remove();
};
});
//$(文档).ready(函数()的结尾{
});

在代码中修复以下问题:

}, {
        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() {

});
//开始$(文档).ready(函数(){
$(文档).ready(函数(){
$('.custom right Box a')。悬停(函数(){
$(this.append('ClickHere');
$('.click here').stop().animate({
宽度:“88px”,
高度:'58px',
marginLeft:“-44px”,
marginTop:“-40px”
}, {
持续时间:300
});
},函数(){
$('.click here').stop().animate({
宽度:“0px”,
高度:“0px”,
marginLeft:“-0px”,
marginTop:“-0px”
}, {
持续时间:300
},
函数(){
$('.click here').remove();
});
});
//$(文档).ready(函数()的结尾{
});

伙计们!感谢所有帮助过我的人。基本上Nelson告诉我的那一点很重要,所以谢谢你,我也不得不改变:-

,{ 持续时间:300 }

只是为了:-

,300

然后回调成功了:-)这是最后的代码(在我做其他更改之前):-

//开始$(文档).ready(函数(){
$(文档).ready(函数(){
$('.custom right Box a')。悬停(函数(){
$(this.append('ClickHere');
$('.click here').stop().animate({
宽度:“88px”,
高度:'58px',
marginLeft:“-44px”,
marginTop:“-40px”
}, 300);
},函数(){
$('.click here').stop().animate({
宽度:“0px”,
高度:“0px”,
marginLeft:“-0px”,
marginTop:“-0px”
},300,函数(){
$('.click here').remove();
});
});
//$(文档).ready(函数()的结尾{
});

你有一个
在结尾的错误位置。包括什么不起作用。什么起作用等等。帮助社区帮助你。我的意思是动画可以工作,但是$('.click here')。remove();bit没有。我把它放错地方了吗?我希望在动画完成后将其删除,以使所有值都为0px。ThanksIt没有任何区别。动画与以前一样工作正常,但之后不会删除di:-(为我工作。+1
// 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() {
});