0
        $("#theDiv").hover(function(){
            $(this).animate( {top: "300px", left: "400px", width: "50px" , height: "50px" },"Fast")
        }); 

        $("#theDiv").click(function(){
            $(this).stop();
        }); 

上記のコード。クリックするとホバー機能を止めようとしたのですが、うまくいきません。それともまったく不可能ですか?

4

2 に答える 2

1
$("#theDiv").mouseenter(function(){
    $(this).animate( {
        top: "300px",
        left: "400px",
        width: "50px" ,
        height: "50px"
    } , "fast");
}).click(function(){
    $(this).stop(true, false);
});

.stop( [クリアキュー] [, jumpToEnd] )

于 2012-07-09T02:54:51.857 に答える
0
$("#theDiv").on({
    mouseenter: function() {
        $(this).animate( {top: "300px", left: "400px", width: "50px" , height: "50px" },"Fast");
    },
    click: function() {
        $(this).off('mouseenter').stop(true);
    }
});

フィドル

于 2012-07-09T02:54:09.270 に答える