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/