(2017) I used $('#'+id).removeAttr().off('click').on('click', function(){...});
I tried $('#'+id).off().on(...) , but resetting the onClick attribute on every call to reset will fail.
I am using .on('click',function(){...}); to avoid having to quote the lock of all my JavaScript functions.
O.P. can now use:
$(this).removeAttr('onclick').off('click').on('click', function(){ displayCalendar(document.prjectFrm[ia + 'dtSubDate'],'yyyy-mm-dd', this); });
For me, this happened when my div was set with the onClick attribute statically set:
<div onclick = '...'>
Otherwise, if I only had a dynamically connected listener, I would use $('#'+id).off().on('click', function(){...}); .
Without turning off ('click'), my onClick listeners were added, not replaced.
JSG Sep 06 '19 at 18:22 2019-09-06 18:22
source share