jquery How to get multiple input values

Source: Internet
Author: User

1 if ($ ("Input[name=item][value= ' Val ')"). attr (' checked ') ==true)//Determine if a tick has been made

Name is the control Name property, and value is the control's Value property
You can not specify a property value, because the value of a set of checkboxes will hold its corresponding ID in the database, preferably written as follows
if ($ ("Input[name=row_checkbox]"). attr (' checked ') ==true)
{
Alert ("J");
}
Else
{
Alert ("Please select data! ");
}
Alternatively, you can write if ($ ("[Name=row_checkbox]"). attr (' checked ') ==true)


jquery Radio value, checkbox value, select Value, Radio selected, CheckBox selected, select selected, and its related

article Category: Web Front end
jQuery 1.3. Under version 2
jquery Radio value, checkbox value, select Value, Radio selected, CheckBox selected, select selected, and its related
Set
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]"). Text ();
gets the text of the Select selected item: var item = $ ("Select[name=items] option[selected]"). text (); or $ ("Select[name=items]"). Find (" Option:selected "). Text ();
the second element of the Select drop-down box is the currently selected value: $ (' #select_id ') [0].selectedindex = 1;
Select drop-down box value = ' val ' element is currently selected: $ ("Select[name=items] option[value= ' Val ']"). attr ("Selected", "selected");
the second element of the radio Radio Group is the currently selected item: $ (' input[@name =items] '). Get (1). checked = true; or $ (' input[name=items] '). attr ("Checked", ' 1 );
Radio value = ' val ' element is currently selected: $ (' input[name=items] [value= ' Val '] '). attr ("Checked", "checked");

Get Value:
text box, text area: $ ("#txt"). attr ("value");
Multi Box checkbox:$ ("Input[name= ' checkbox ': Checked]"). each (function () {
var val = $ (this). Val ();
});
Radio Group Radio: $ ("input[type=radio][checked]"). Val ();
The value of the drop-down box select is: $ (' select '). val ();
Drop -down box select the text value selected: $ ("select"). Find ("option:selected"). Text ();
Control form elements:
text box, text area: $ ("#txt"). attr ("value", ");//Clear Contents
$ ("#txt"). attr ("value", ' 11′ ');//fill content
multiple marquee checkbox:
the second element of the checkbox is ticked: $ ("Input[name=items]"). Get (1). checked = true;//tick
$ ("Input[name=items]"). Get (1). checked = false;//do not tick
checkbox value= ' val ' element before tick: $ ("Input[name=item][value= ' Val ')"). attr ("Checked", true); or $ ("input[name=item][ Value= ' Val '] "). attr (" Checked "," checked ");
if ($ ("Input[name=item][value= ' Val ')"). attr (' checked ') ==true)//Determine if a tick has been made
Radio Group Radio: $ ("Input[type=radio]"). attr ("Checked", ' 2′ ');//Set value=2 items as the current selection
Drop- down box select: $ ("#sel"). attr ("value", '-sel3′ ');//Set the VALUE=-SEL3 item as the current selection
$ ("<option value= ' 1′>1111</option><option value= ' 2′>2222</option>"). AppendTo ("#sel") option to add a drop-down box
$ ("#sel"). empty ();//Empty drop-down box
jquery Gets the value of the radio selection
Code
$ ("Input[name= ' Radio_name '][checked]"). Val ();//Select the value of the selected radio
$ ("#text_id"). focus (function () {//code ...})//event triggered when object text_id gets focus
$ ("#text_id"). blur (function () {//code ...})//event triggered when object text_id loses focus
$ ("#text_id"). Select ();//Make the Vlaue value of the text box selected
$ ("Input[name= ' radio_name '][value= ' to select Radio Value '").
attr ("checked", true);//Set radio as selected based on value values
jquery Gets the value of the checkbox selection
$ ("Input[name= ' Checkbox_name '][checked]");//Select a collection of selected checkbox elements if you want to
value you need to traverse this collection
$ ($ ("Input[name= ' Checkbox_name '][checked]")).
Each (function () {arrchk+=this.value + ', ';}); /Traverse the collection of selected checkbox elements to get value values
$ ("#checkbox_id"). attr ("checked");//Get the status of a checkbox (there is no selection, return True/false)
$ ("#checkbox_id"). attr ("Checked", true);//Set the status of a checkbox to checked (checked=true)
$ ("#checkbox_id"). attr ("checked", false);//Set a checkbox with a status of unchecked (Checked=false)
$ ("Input[name= ' Checkbox_name ']"). attr
("Checked", $ ("#checkbox_id"). attr ("checked"));//According to the 3,4,5 bar, you can analyze the meaning of this code
$ ("#text_id"). Val (). Split (",");//Returns an array of value values of text as ', ' delimited

jquery How to get multiple input values

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.