jquery Gets the value of the Radio,checkbox selection (sample code) _jquery

Source: Internet
Author: User

$ ("Input[name= ' Radio_name '][checked]"). Val (); Select the value of the selected radio
$ ("#text_id"). focus (function () {//code ...}); Event is triggered when object text_id gets focus
$ ("#text_id"). blur (function () {//code ...}); Event is triggered when the 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 value of the checkbox selection

$ ("Input[name= ' Checkbox_name '][checked]");//Select a collection of selected checkbox elements if you want the value you need to traverse this set
$ ($ ("input[name=") Checkbox_name '][checked] ").
each (function () {arrchk+=this.value + ', ';}); /Traverse the collection of the selected checkbox element to get the value
$ ("#checkbox_id"). attr ("checked");//Get the State of a checkbox (has not been checked, return True/false)
$ (" #checkbox_id "). attr (" Checked ", true); Sets the status of a checkbox to be checked (checked=true)
$ ("#checkbox_id"). attr ("checked", false);//Set the status of a checkbox unchecked (checked= FALSE)
$ ("Input[name= ' Checkbox_name ']"). attr
("Checked", $ ("#checkbox_id"). attr ("checked"))//According to 3,4,5, You can analyze and analyze the meaning of this Code
$ ("#text_id"). Val (). Split (",");//return an array with the value of text as ', ' delimited

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.