[英]How to select all fields in form with particular class
I am trying to select all fields in form with a specific calls name and later on to select all the rest. 我试图选择具有特定呼叫名称的表单中的所有字段,然后选择所有其余字段。
my form: 我的表格:
<form style="margin:20px 0" id="myform_2">
<p> Query Name :
<input id="full_text_search" name="name" type="text" class="serialize_1">
</p>
<p> Platform :
<select multiple="multiple" style="width:370px" id="platform" name="platform" class="serialize_1">
<option value="android" selected="selected">Android</option>
<option value="ios">IOS</option>
</select>
</p>
<p> Full Text Search :
<input id="full_text_search" name="full_text_search" type="text">
</p>
<p> Package Name :
<input id="package_name" name="package_name" type="text">
</p>
</form>
I want the first selector to select the inputs with class:"serialize_1". 我希望第一个选择器用类选择输入:“serialize_1”。 so i try this:
所以我试试这个:
$('#myform_2 :input[class==serialize_1"]');
and the second selector to catch all the rest so i try this: 和第二个选择器捕获所有其余的所以我试试这个:
$('#myform_2 :input[class!=serialize_1"]');
what am i missing? 我错过了什么?
Thanks 谢谢
To get with class: 上课:
$('#myform_2 :input.serialize_1');
To get without class: 没有上课:
$('#myform_2 :input:not(.serialize_1)');
to get class use selector '.' 获取类使用选择器'。'
$('#myform_2 :input.serialize_1');
- select the inputs with class:"serialize_1" - 使用类选择输入:“serialize_1”
$('#myform_2 :input:not(.serialize_1)');
- selector to catch all the rest - 选择器以捕获所有其余的
Just use the class selector to select the serialize_1
elements, and the not()
selector method to select the ones that are not: 只需使用类选择器选择
serialize_1
元素,使用not()
选择器方法选择不是:
$('#myform_2 :input').not('.serialize_1').addClass('blue');
$('#myform_2 :input.serialize_1').addClass('red');
Here is a 这里有一个
WORKING TEST 工作测试
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.