简体   繁体   English

必须更改鼠标移出事件中的单击事件

[英]have to Change click event mouse in mouse out event

With below script written for click event. 下面的脚本为click事件编写。 I want to use Same code(selectors) for Mouse in, mouse out event 我想使用相同代码(选择器)进行鼠标移入,鼠标移出事件

 $('.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");
        });
    })

}

Try this approach... 试试这个方法...

function yourFunction(){
   //your code here
}

$("#yourSelector").hover(
    yourFunction(), 
    yourFunction()
);

You can try this: 您可以尝试以下方法:

$('.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");
    });
})

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM