- February 8, 2017
- Posted by: user
- Category: Uncategorized
I just came across this problem that is happening in IE. In the html I am adding an onclick event to an element that calls a function ‘changeStatus’ like this :
Inside the changeStatus function I added the .unbind(‘click’).removeAttr(‘onClick’); in order to remove the old onclick event and then add the new one.
This is working fine in FF, but in IE it is calling both the new click event and the old at the same time for some reason. I think that this causes jQuery to not know what events are taking place elsewhere, so both events get run.
When I put the following code and just bind the click event with jquery on document.ready and not set the onclick attribute of the anchor tag.
This is works well on both FF and IE and I believe that this is the best way to fix this problem.
Please correct me if this is wrong logic or any other way to fix this problem.