想给除 input:type=button,submit,reset 之外的所有表单元素添加 css class。
我使用了这个 jquery 代码。
$("input").each(function () {
$(this).addClass("form-control");
});
$("select").each(function () {
$(this).addClass("form-control");
});
我想排除提交、按钮和重置。我知道如何在 jquery 的每个函数中手动添加输入类型,但我想知道是否要使用 jquery 排除某些类型。
最佳答案
您可以使用 .not() 排除按钮和重置按钮, button-selector和 reset-selector
$("input, select, textare").not(':button, :reset')
关于jquery - 将类添加到除按钮之外的所有输入类型,使用 jquery 提交和重置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26523387/