jQuery disable all button of a css class

后端 未结 4 729
暖寄归人
暖寄归人 2021-01-04 05:36

I have n buttons. This button has the same name: setAlg.

I would disable all the buttons that has this name.

I have tried

$(\"input[name=         


        
4条回答
  •  失恋的感觉
    2021-01-04 06:20

    Make sure to wrap your code in ready handler:

    $(function(){
      $("input[name='setAlg']").attr("disabled", true);
    });
    

    But If you are using the same class for those input fields (as per your question title), you need to try this instead:

    $(function(){
      $("input.myclass").attr("disabled", true);
    });
    

    Where myclass is supposed to be the class name used for those input fields.

提交回复
热议问题