The checbox check box implements the single-choice function of radio single-choice, checboxradio

Source: Internet
Author: User

The checbox check box implements the single-choice function of radio single-choice, checboxradio

The checbox check box implements the single-choice function of radio single-choice:
You know that multiple check boxes can be selected at a time, and only one of them can be selected at a time. However, after you select one of them, only one of them can be selected, all of the following functions of the single-choice button are simulated through the checkbox check box, but the selected items can be canceled.
The Code is as follows:

<! DOCTYPE html> 

The above code implements the functions we want. The following describes the implementation process.
I. Code comments:
1. $ (function () {}). After the file structure is fully loaded, run the code in the function.
2. $ (": checkbox"). click (function () {}), register the click event handler function for the checkbox check box.
3. if ($ (this). attr ("checked ")! = Undefined) {} to check whether the current check box is selected, because if the check box is not selected, the return value of the attr () function is undefined, and if it is selected, the return value is checked.
4. $ (this). siblings (). attr ("checked", false). If the current click is selected, deselect all its sibling check boxes.
Ii. Related reading:
1. For more information about the attr () function, see the attr () method section of jQuery.
2. For details about the siblings () function, refer to the siblings () method section of jQuery.

The original address is: http://www.softwhy.com/forum.php? Mod = viewthread & tid = 14449.

For more information, see: http://www.softwhy.com/jquery/

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.