Talk less, first post code, and then briefly describe the small difficulties encountered ... is the green font in the code;DOCTYPE HTML>HTMLLang= "en">Head> MetaCharSet= "UTF-8"> title>3title>Head>Body> ButtonID= "All_yes">Select AllButton> ButtonID= "All_no">Not selectedButton> ButtonID= "ALL_EX">Inverse selectionButton> inputtype= "checkbox"na
First to show you the effect of the picture, if you feel good, please continue to refer to the implementation code.
HTML code:
jquery code:
Note: Due to the changes in the jquery version, the new version appears only once, the older version is OK, the new version can not use attr to set the selected state, the first solution is to use the JS native method This.checked=true/false;
The second solution is to replace attr
In the construction of the site, let the check box and all the cancellation is more commonly used, the following describes how to use a sentence to solve the full selection function;In fact, it is very simple, that is, using the function of counting jquery deprecated the last piece of code in this article;Well, the method I want to introduce is finished;Well, don't smash the eggs; I'm kidding. The code is belowJavaScript section:function Checkall (obj) {$ ("#box input[type= '
In the construction of the site, let the check box and all the cancellation is more commonly used, the following describes how to use a sentence to solve the full selection function;In fact, it is very simple, that is, using the function of counting jquery deprecated the last piece of code in this article;Well, the method I want to introduce is finished;650) this.width=650; "alt=" u=3644218134,974193839fm=21gp=0_ copy. jpg "src=" http://www.baijunyao.com/Upload /image/ueditor/20150429/1430237383
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 = $
Gets the value of a set of radio selected itemsvar item = $ (' input[@name =items][@checked] '). Val ();Gets the text of the Select selected itemvar item = $ ("select[@name =items] option[@selected]"). Text ();The second element of the Select Drop-down box is the currently selected value$ (' #select_id ') [0].selectedindex = 1;
Radio the second element of a radio
In the construction of the site, let the check box and all the cancellation is more commonly used, the following describes how to use a sentence to solve the full selection function; In fact, it is very simple, that is, using the function of counting jquery deprecated the last piece of code in this article; Well, the method I want to introduce is finished; Well, don't smash the eggs; I'm kidding. The code is below JavaScript section: function Checkall (obj) {$ ("#box input[type= '
[Html]JQuery gets the selected Text and Value of Select:Syntax explanation:1. $ ("# select_id"). change (function () {// code...}); // Add an event for Select, triggered when one of the Select events is selected2. var checkText = $ ("# select_id"). find ("option: selected"). text (); // obtain the selected Text3. var checkValue = $ ("# select_id"). val (); // obt
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 = $ ("
);
} 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="
1
2. $ ("# select_id"). val (4); // Select an item whose Value is set to 4.
3. $ ("# select_id option [text = 'jquery ']"). attr ("selected", true); // set the Select Text value to jQuery.
JQuery adds/deletes Select Option items:
Syntax explanation:
1. $ ("# select_id"). append ("
Text"); // Append an Option to Select
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 = $ ("
selected item from the drop-down menu.Var cc3 = $ ('. formc select [@ name = "country"]'). attr ("id"); // obtain the ID attribute value of the selected item from the drop-down menu$ ("# Select"). empty (); // clear the drop-down box // $ ("# select" example .html ('');$ ("1111"). AppendTo (" #
selected item from the drop-down menu.Var cc3 = $ ('. formc select [@ name = "country"]'). attr ("id"); // obtain the ID attribute value of the selected item from the drop-down menu$ ("# Select"). empty (); // clear the drop-down box // $ ("# select" example .html ('');$ ("1111"). AppendTo (" #
The Checkbox,radio of jquery, and select, is a difficult and focused aspect of jquery operations, and many front-end novices don't understand it very well. A long time no, I am in the writing sometimes it is inevitable to some of the operation of the shuffle, remember not clearly, now, to do some simple summary!
1, CheckBox daily jquery operation.
Now let's tak
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.