Brett
Brett

Reputation: 20049

Trigger javascript function when a button is disabled?

If I am using a submit button as so..

<input type="image" name="submit" src="image.png" disabled="disabled" />

Is there any way I can trigger a Javascript alert when someone clicks this button? I have tried using onclick() but it doesn't work unless I take away the disabled="disabled".

Upvotes: 1

Views: 705

Answers (1)

the system
the system

Reputation: 9336

No, the disabled setting also disables events.

If you need behavior to remain, then instead of disabling it, you should just keep it enabled, and enforce the behavior you want based on some flag added to the element, like a class or some other property on the element.

Upvotes: 6

Related Questions