jQuery disable all button of a css class

后端 未结 4 707
暖寄归人
暖寄归人 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:11

    Chris Pebbles suggestion should work fine, but I am confused. In your question's title, you specificall state "jQuery disable all button of a css class", however, you then provide an example which shows that you really want to disable all buttons that have a name attribute of setAlg.

    Two points come to mind. First, your buttons, since they all have the same name may produce unexpected results for you when the user submits your form (if this is what they do, but I may be wrong here). If this is the case, the you probably really do want to set all of them to the same class, not name.

    ...
    

    Second point is that if you do want to make your jQuery to work with a class, you'll need to do:

    $("input.setAlg").attr("disabled","disabled");
    

    I hope this was helpful.

提交回复
热议问题