1

ボックスに .off を使用してイベント ハンドラーを削除できません。

ボックスがクリックされたら、そのボックスのイベント ハンドラーを削除する必要があります。現在、フック ".clickable" を作成してクラスを削除し、イベント ハンドラーを削除してから、" のクラスを持つすべてのボックスにイベント ハンドラーを適用し直しました。 。箱"。

        $('.clickable').off('click','**').on("click", function(event){

        if( !$('.box').is(':animated') ) {

            var position = $(this).position()
            ,   targetPosition =  $('.target').position();

            $(this)
                .clone() //clone element
                .addClass('cloned') //add class to cloned element
                .css({
                    'position' : 'absolute'
                ,   'top' : position.top 
                ,   'left' : position.left 
                })
                .appendTo('body'); //append to the document

                animate(position,targetPosition);

                $(this)
                    .removeClass('clickable')
                    .addClass('notActive');

        };

    });

あなたのアドバイスと助けに感謝します。誰かが最終的なデモが「機能している」のを見たい場合は、フィドルです

作業バージョン

4

1 に答える 1