As I mentioned in the title, I would like to prevent an event from being triggered when I fire another one:
Let's take this example:
$(function() { $("#security_code").bind('change', function () { // Do validation and show errors }); $("#reloadCaptcha").bind('click', function () { // generate new captcha and clear 'secuirity code' field // clear the field so the user will enter the new generated security code document.getElementById('security_code').value = ''; }); }); PURPOSE: prevent the 'change' event from being fired when the '#reloadCaptcha' is clicked.
When I click the link (second event) the first event fires too (since 'change' activates). I am looking to stop all "change" events when a link is actually clicked. I hope I was clear enough. Does anyone have any ideas?
And yes, I've tried unbind, stopPropagation and other functions from the jQuery documentation, but it just didn't work.
Note that I only want to have the "change" freezed when I click that specific link. In other cases, it should work all the time.
Thanks in advance guys! I hope there is someone out there that can clarify this for me.
#link_idelement changing the value of the#usernamefield, and thats why the change event fires? Just looking for clarification