Jquery changes the selection status of radio/checkbox and obtains the selected value.
This article mainly introduces how Jquery changes the selection status of radio/checkbox. If you need to obtain the selected value (sample code), you can refer to it for help.
// If the selected one exists, cancel the selected radio.
$ ("# Tj_cat. pro_category"). each (function ()
{
If ($ (this). attr ('checked ')){
$ (This). attr ('checked', false );
}
});
// Obtain the value of the selected tag
Radio :( checkbox is the same as this one)
Var val = $ ('input: radio [name = "sex"]: checked'). val ();
// The following statement can also be used.
// Var val = $ ('. sexclass: checked'). val ();
Select:
Var sel_val = $ ("select [id = 'shuini '] option: selected"). val ();
// The following statement can also be used.
// Var sel_val = $ ('. must_write option: selected'). val ();
// Var sel_val = $ ('# shuini option: selected'). val ();
// Var sel_val = $ ("select [name = 'shanghai1'] option: selected"). val ();