Clicking a disabled input or button

后端 未结 9 1409
星月不相逢
星月不相逢 2020-11-28 13:12

Is it possible to click on a disabled button and provide some feedback to the user?

HTML:




        
相关标签:
9条回答
  • 2020-11-28 14:05

    You should used disabled="disabled" and not just disabled.

    $('input:disabled').val('disabled');
    
    0 讨论(0)
  • 2020-11-28 14:10

    Making the field readonly can help, because the click event will be fired. Though be aware of the differences in behaviour.

    <input type="button" value="click" readonly="readonly" />
    
    0 讨论(0)
  • 2020-11-28 14:11

    <input id="idButton" type="button" value="click" disabled>

    $('#idButton').on('click', function() {
        // The button is disabled but this will be executed.
    });
    

    The above example works with JQuery for disabled buttons that need the event to be captured.

    0 讨论(0)
提交回复
热议问题