必须更改单击事件鼠标输入鼠标输出事件

have to Change click event mouse in mouse out event

本文关键字:鼠标 输入 输出 出事件 事件 单击      更新时间:2023-09-26

下面的脚本是为点击事件编写的。我想对鼠标输入、鼠标输出事件使用相同的代码(选择器)

 $('.tools_collapsed').wrap('<div class="newparent" />');
    var speed = 600;
    $('.tools_collapsed').show().css({ right: '-250px' }).hide();
    $('.tools_collapsed .collapse_btn').hide();
    $('.tools_expand').click(function () {
        $('.tools_collapsed').show().animate({ right: '0' }, { duration: speed });
        $('.tools_collapsed .collapse_btn').show();
    })
    $('a.collapsed').click(function () {
        $('.tools_expand').css({ display: 'none' });
        $('.tools_collapsed').animate({ right: '-250', easing: 'easeOutQuad' }, 400, function () {
            $('.tools_collapsed .collapse_btn').css("display", "none");
            $('.tools_expand').show("normal");
        });
    })
}

尝试这种方法。。。

function yourFunction(){
   //your code here
}
$("#yourSelector").hover(
    yourFunction(), 
    yourFunction()
);

你可以试试这个:

$('.tools_collapsed').wrap('<div class="newparent" />');
var speed = 600;
$('.tools_collapsed').show().css({ right: '-250px' }).hide();
$('.tools_collapsed .collapse_btn').hide();
$('.tools_expand').on( "mouseenter",function () {
    $('.tools_collapsed').show().animate({ right: '0' }, { duration: speed });
    $('.tools_collapsed .collapse_btn').show();
})
$('.tools_expand').on( "mouseout", function () {      // changed from "a.collapsed"
    $('.tools_expand').css({ display: 'none' });
    $('.tools_collapsed').animate({ right: '-250', easing: 'easeOutQuad' }, 400, function () {
        $('.tools_collapsed .collapse_btn').css("display", "none");
        $('.tools_expand').show("normal");
    });
})