2

How to set the event for a disabled button in jquery. I want to show a message when the mouse enter into the disabled button. But now there is no event not occur while mouse enter the disabled button.

kalles
  • 337
  • 1
  • 6
  • 22

1 Answers1

0

Try like this:

<div id="myid"><input type="submit"><div>

$('myid').click(function(event){
    if (attr('submit-button', 'disabled') == 'true')
    {
        alert('The button is disabled')
    }
});

Also check this forum:

Firefox, and perhaps other browsers, disable DOM events on form fields that are disabled. Any event that starts at the disabled form field is completely canceled and does not propagate up the DOM tree. Correct me if I'm wrong, but if you click on the disabled button, the source of the event is the disabled button and the click event is completely wiped out. The browser literally doesn't know the button got clicked, nor does it pass the click event on. It's as if you are clicking on a black hole on the web page.

Rahul Tripathi
  • 168,305
  • 31
  • 280
  • 331