简体   繁体   English

如何选择具有特定类的表单中的所有字段

[英]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.

相关问题 如何获取我单击的特定表单的输入字段的值,所有 forms 及其输入具有相同的 class 但值不同 - How to get the value of input fields of a particular form on which i clicked ,all the forms and their input have the same class but different value 如何使用Prototype选择给定表单元素中的所有表单域? - How to select all form fields within a given form element with Prototype? jQuery-如何选择具有相同类但不具有特定ID的所有元素 - jQuery - How to select all elements with same Class but not with particular ID 选择所有具有特定ID AND类的元素 - Select all the elements that have a particular id AND class 禁用除特定类之外的所有表单元素 - Disable all form elements except particular class 当选择框上的选择更改时,请更改具有特定类的所有表单字段的值 - When selection upon a select box changes, change the value for all form fields with a certain class 如何为JQuery选择器选择属于类而不是类的所有元素的特定HTML元素 - how to select the particular HTML element which is part of a class and not all the elements of a class for JQuery selectors 特定字段形式的滚动条 - A scrollbar in form for particular fields 如何选择所有复选框,但不选择特定复选框? - How to select all checkboxes but unselect a particular checkbox? 如何获取 class 中的所有字段 - How to get all fields in class
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM