. $ ("# select_id option: last"). remove (); // Delete the largest Option (last) index value in Select)4. $ ("# select_id option [index = '0']"). remove (); // Delete the Option with the index value 0 in Select (the first option)5. $ ("# select_id option [value = '3']"). remove (); // Delete the Option with Value = '3' In the Select statement5. $ ("# select_id option [text = '4']"). remove (); // Delete the Option of '4' Text = '4' in SelectHttp://www.cnblogs.com/SAL2928/archive/2008/10/28/13212
with attributes and properties. But the old. attr () method has some bugs that are difficult to maintain. jQuery1.6.1 has updated the Attributes module and fixed several bugs.
In particular, the Boolean attributes, such as: checked,selected,readonly and disabled are treated the same as before 1.6.1 and 1.6. This means the following code:
$ (": CheckBox"). attr ("Checked", true); $ ("option"). attr ("selected", true); $ ("
). val ())} unchecked value})})})CheckBox Delete:$ ("Checkboxid"). Remove ();TXT text box check:$ ("#txtid"). Val ();TXT text box change:$ ("#txtid"). Val ("xx");txt text box Delete:$ ("#txtid"). Val ("");jquery Radio value, checkbox value, select Value, Radio selected, CheckBox selected, select selected, and its relat
);
} else{
$ ("#SelectAll"). attr ("checked", false);}
}
The ID of the Select checkbox is SelectAll, and the name of the sub-checkbox is Subcheck.The JSP page code is as follows:[HTML]View PlainCopy
input type="checkbox" id="SelectAll" value="Select All" onclick="SelectAll ();" />
because one method was used in all versions prior to 1.6 (. attr ()) To deal with attributes and properties. But the old. attr () method has some bugs that are difficult to maintain. jQuery1.6.1 has updated the Attributes module and fixed several bugs.In particular, the Boolean attributes, such as: checked,selected,readonly and disabled are treated the same as before 1.6.1 and 1.6. This means the following code:JS Code
$ (": CheckBox"). attr
1. Get a single checkbox check (three ways)$ ("input:checkbox:checked"). Val ()Or$ ("input:[type= ' checkbox ']:checked"). Val ();Or$ ("input:[name= ' ck ']:checked"). Val ();2. Get multiple checkbox check items$ (' Input:checkbox '). each (function () {if ($ (this). attr ('
is used in all versions earlier than 1.6 (. attr () to process attributes and properties. However, the old. attr () method has some bugs and is difficult to maintain. JQuery1.6.1 updated the Attributes module and fixed several bugs.
In particular, boolean attributes, such as checked, selected, readonly, and disabled are processed the same way before 1.6.1 and 1.6. This means the following code:
Copy codeThe Code is as follows:$ (": Checkbox"). attr (
handle attributes and properties. But the old. attr () method has some bugs that are difficult to maintain. jQuery1.6.1 has updated the Attributes module and fixed several bugs.
Specifically, Boolean attributes, such as: Checked,selected,readonly and disabled, are treated the same as before 1.6.1 and 1.6. This means the following code:
The code is as follows:
$ (": CheckBox"). attr ("Checked", true);
$ ("option"). attr ("selected", true);
$ (
because a method (. attr ()) was used in all versions prior to 1.6. To handle attributes and properties. But the old. attr () method has some bugs that are difficult to maintain. jQuery1.6.1 has updated the Attributes module and fixed several bugs.
Specifically, Boolean attributes, such as: Checked,selected,readonly and disabled, are treated the same as before 1.6.1 and 1.6. This means the following code:
Copy Code code as follows:
$ (": C
jquery's Checkbox,radio, and select are a difficult and important point for jquery operations, and many front-end novices are not very thorough about it. Long time no, I write sometimes also unavoidably on some operations, remember not clear, now, do some simple summary!1, CheckBox daily jquery operation.Now let's use
Jquery radio, checkbox, select, radio, checkbox, select, and relatedObtains the value of a set of radio selected items.Var item = $ ('input [@ name = items] [@ checked] '). val ();Obtain the text of the selected select item.Var item = $ ("select [@ name = items] option [@ selected]"). text ();The second element in the
earlier, jQuery1.6.1 allows you to use the. attr () method just as it used to be in all cases.2. What has changedThe change in the attributes module was to remove ambiguities between the attributes and properties, but it caused some confusion in the jquery community because one method was used in all versions prior to 1.6 (. attr ()) To deal with attributes and properties. But the old. attr () method has some bugs that are difficult to maintain. jQue
JQuery is used to simplify operations on form elements such as radio, checkbox, select, and radio, and jquerycheckbox.
Obtains the value of a set of radio selected items.Var item = $ ('input [@ name = items] [@ checked] '). val ();Obtain the text of the selected select item.Var item = $ ("select [@ name = items] option [@ selected]"). text ();The second element i
JQuery verifies whether the Checkbox code is selected. For more information, see. We recommend that you read the articles related to the home of your feet. Most people think of this method for verification estimation:
The Code is as follows:
Function chk () // check whether the selected return true and no return false are selected.{Var falg = 0;$ ("Input [n
The following jquery code is suitable for query1.4 version.
1. Get the selected value, three methods can be:
$ (' input:radio:checked '). Val ();
$ ("input[type= ' Radio ']:checked"). Val ();
$ ("Input[name= ' rd ']:checked"). Val ();
2. Set the first radio to the selected value:
$ (' Input:radio:first '). attr (' checked ', ' checked ');
Or
$ (' Input:ra
Jquery radio, checkbox, select, radio, checkbox, select, and related
Obtains the value of a set of Radio selected items.
VaR item = $ ('input [@ name = items] [@ checked] '). Val ();
Obtain the text of the selected select item.
VaR item = $ ("select [@ name = items] Option [@ selected]"). Text ();
The second element in
jquery Radio value, checkbox value, select Value, Radio selected, CheckBox selected, select selected, and related
Gets the value of a set of radio selected items
var item = $ (' input[@name =items][@checked] '). Val ();
Gets the text of the Select selected item
var item = $ ("select[@name =items] option[@selected]"). T
Since the version of jquery has been updated very quickly, the code has changed a lot, the following jquery code is suitable for query1.4 version aboveRadio1. To get the selected value, three methods are available:$ (' input:radio:checked '). Val ();$ ("input[type= ' Radio ']:checked"). Val ();$ ("Input[name= ' rd ']:c
Summing up the actual development of the checkbox combining jquery Common Properties and events:
1,checkbox how the selected state changes:
$ (function () {$ ("#basketBall"). Change (function () {Alert ("BASEketball changing");});})
2,checkbox selected:
Select all the checkboxThe first: $ ("
As shown in the figure above, (using the table plugin in jquery) The effect I wanted was: click the checkbox (id "all") in the upper-left corner, and all the checkboxes below (id "CB") will all be selected. The jquery code I started with was this:
$ ("#all"). Toggle (function () {$ (": CheckBox"). attr ("Checked", "tru
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.