Consider the following code:
$('a').attr('disabled', 'disabled');
In IE and FF, this will make anchors unclickable, but in WebKit based browsers (Google Chrome and Safari) this does nothing. The nice thing about the disabled attribute is that it is easily removed and does not effect the href and onclick attributes.
Do you have any suggestions on how to get the desired result. Answers must be:
- Easily be revertable, since I want to disable form input controls while I have an AJAX call running.
- Must work in IE, FF, and WebKit
I assume that you have an onclick event handler bound to these anchor elements. Just have your event handler check the ‘disabled’ attribute and cancel the event if it is set. Your event handler would look something like this:
You can also set a stylesheet rule to change the cursor.
Edit – simplified the ‘disabled’ check as suggested in comments.