jquery - Removing event handler with .off -
i unable remove event handler using .off boxes.
once box clicked need event handler removed box, have made hook ".clickable" , remove class , tried remove event handler apply event handler boxes class of ".box".
$('.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 cloned element .css({ 'position' : 'absolute' , 'top' : position.top , 'left' : position.left }) .appendto('body'); //append document animate(position,targetposition); $(this) .removeclass('clickable') .addclass('notactive'); }; }); thanks advice , help, if see final demo "working" here fiddle
correction code, haven't tested should work
$(document).on("click", '.clickable', function(event){ if( !$('.box').is(':animated') ) { var position = $(this).position(); var targetposition = $('.target').position(); $(this) .clone() //clone element .addclass('cloned') //add class cloned element .css({ 'position' : 'absolute' , 'top' : position.top , 'left' : position.left }) .appendto('body'); //append document animate(position,targetposition); $(this) .removeclass('clickable') .addclass('notactive') .off('click'); }; });
Comments
Post a Comment