Disable button in jQuery

后端 未结 11 1729
时光说笑
时光说笑 2020-11-28 02:04

My page creates multiple buttons as id = \'rbutton_\"+i+\"\'. Below is my code:

11条回答
  •  难免孤独
    2020-11-28 02:40

    There are two things here, and the highest voted answer is technically correct as per the OPs question.

    Briefly summarized as:

    $("some sort of selector").prop("disabled", true | false);
    

    However should you be using jQuery UI (I know the OP wasn't but some people arriving here might be) then while this will disable the buttons click event it wont make the button appear disabled as per the UI styling.

    If you are using a jQuery UI styled button then it should be enabled / disabled via:

    $("some sort of selector").button("enable" | "disable");
    

    http://api.jqueryui.com/button/#method-disable

提交回复
热议问题