views:

96

answers:

2

Hi,

I would like to perform the click event of a element:

jQuery('input#submit').click(function() {

 if ( jQuery('input#submit').attr("disabled") ) { 
     alert('SUP');
 }

});

However this will not work as the element is required to be enabled for the click even to be executed.

Any help would be appreciated,

Thanks

+2  A: 

Why would you want the click event to work for the disabled button? Your best bet would be to keep the button enabled, but only have it 'work' if some other condition is met, by preventing the button from causing a submit by returning false. E.g.:

jQuery('input#submit').click(function(e) {
        if ( something ) {        
            return false;
        } 
});
karim79
+1  A: 

Not very clear what you want. You cant click a disabled element. In order to click it you will have to enable it like so.

jQuery('#someInputId').attr('disabled', false);

There is no way around it.

If you want the same functionality you could just submit the form e.g $('#formId').submit();

redsquare