JQuery gets the Value of the sample code selected by Radio CheckBox

  • 2020-03-30 00:53:41
  • OfStack

$(" input [name = 'radio_name] [checked] "). The val (); // select the Value of the selected Radio
$(" # text_id "). The focus (the function () {/ / code... }); The // event is fired when the object text_id gets focus
$(" # text_id "). The blur (function () {/ / code... }); The // event fires when the object text_id loses focus
$(" # text_id "). The select (); // makes the Vlaue value of the text box checked
$("input[name='radio_name'][value=' value value of the Radio to be selected '").
Attr (" checked ", true); // set the Radio to the selected state according to the Value


JQuery gets the Value selected by the CheckBox

$(" input [name = 'checkbox_name] [checked] "); // select the set of selected CheckBox elements that you need to iterate over if you want the Value
$($(" input [name = 'checkbox_name'] [checked] ")).
Each (function () {arrChk + = this. Value + ', '; }); // traverses the collection of selected CheckBox elements to get the Value
$(" # checkbox_id "). Attr (" checked "); // gets the status of a CheckBox (whether checked or not, returns true/false)
$(" # checkbox_id "). Attr (" checked ", true); // set the state of a CheckBox to checked=true
$(" # checkbox_id "). Attr (" checked ", false); // set the state of a CheckBox to unchecked (checked=false)
$(" input [name = 'checkbox_name'] "). The attr
(" checked ", $(" # checkbox_id "). Attr (" checked ")); // according to 3,4,5, you can analyze the meaning of this code
$(" # text_id "). Val (). The split (", "); // returns an array with the Value of Text separated by ','


Related articles: