jQuery的禁用CSS类的所有按钮 [英] jQuery disable all button of a css class
本文介绍了jQuery的禁用CSS类的所有按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有n个按钮。
此按钮具有相同的名称:setAlg
I have n buttons. This button has the same name: setAlg.
我要禁用所有具有此名称的按钮。
I would disable all the buttons that has this name.
我曾尝试
$("input[name='setAlg']").attr("disabled",true);
,但它不工作
我该怎么办?
非常感谢。
推荐答案
请务必将您的code在准备处理程序:
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);
});
其中, MyClass的
被认为是用于这些输入字段的类名。
Where myclass
is supposed to be the class name used for those input fields.
这篇关于jQuery的禁用CSS类的所有按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文