简体   繁体   中英

hover effect after bind an image with mouse

I have this code to bind an image with mouse,

$(function(){
    var $i = $('#gg');
    $( "#gg" ).click(function() {
        $(document).bind('mousemove',function(e){
            $i.css({
                left: e.pageX -42,
                top:  e.pageY -60
            });
        });
    });
});

after bind i want to hide another image on mouseover. Look at this FIDDLE

please give me any idea.

$(function () {
    var $i = $("#gg")
    $i.click(function () {
        $i.css('pointer-events','none');
        $(document).on('mousemove', function (e) {
            $i.css({
                left: e.pageX - 42,
                top: e.pageY - 60
            });
        });
        $('#gg1').one('mouseenter', function() {
            $(this).hide();
        });
    });
});

FIDDLE

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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