Jquery changes the check state of the radio and checkbox to get the selected value of the sample code
- 2020-03-30 00:53:45
- OfStack
// if anything was previously selected, cancel the selected radio
$(" # tj_cat pro_category ".) each (function ()
{
If ($(this). Attr (" checked ")) {
$(this). Attr (" checked ", false);
}
});
// gets the value of the selected tag
Radio :(checkbox is the same as this)
Var val = $(' input: radio [name = "sex"] : checked '). The val ();
// the following way can also be written
/ / var val = $(' sexclass: checked '). The val ();
Select:
Var sel_val = $(" select [id = 'shuini'] option: selected "). The val ();
// the following way can also be written
/ / var sel_val = $(' must_write option: selected '). The val ();
/ / var sel_val = $(' # shuini option: selected '). The val ();
/ / var sel_val = $(" select [name = 'shuini1'] option: selected "). The val ();
$(" # tj_cat pro_category ".) each (function ()
{
If ($(this). Attr (" checked ")) {
$(this). Attr (" checked ", false);
}
});
// gets the value of the selected tag
Radio :(checkbox is the same as this)
Var val = $(' input: radio [name = "sex"] : checked '). The val ();
// the following way can also be written
/ / var val = $(' sexclass: checked '). The val ();
Select:
Var sel_val = $(" select [id = 'shuini'] option: selected "). The val ();
// the following way can also be written
/ / var sel_val = $(' must_write option: selected '). The val ();
/ / var sel_val = $(' # shuini option: selected '). The val ();
/ / var sel_val = $(" select [name = 'shuini1'] option: selected "). The val ();