I’m using jQuery. I have a disabled textarea: <textarea id="textarea" disabled="disabled"></textarea>. I want to make it so that when a user clicks on the textarea, it will do something, such as an alert box. So, I have $('#textarea').click(function() { alert('Test'); });.
However, this only works when the textarea is not disabled. So, how can I make the click event fire even when the textarea is disabled?
Instead of disabling it, you could either try simulating the disabled behaviour with CSS and continue receiving mouse events from it.
Or see this answer Event on a disabled input
where
Andy Eshows how you can place an invisible element (an overlay) on top of the input for receiving those mouse events when the input is disabled.He removes the overlay and enables the input when it is clicked, but you could change the behavior to anything you’d like.