Home >Web Front-end >JS Tutorial >Summary of common jquery operations on radio button, multi-select box, text box and other operations_javascript skills
Summary of common jquery operations on radio button, multi-select box, text box and other operations_javascript skills
WBOYOriginal
2016-05-16 17:04:511293browse
1. Text boxes, radio buttons, check boxes, related operations
var sex=$("input[name='sex']:checked").val(); //Get a set of radio selected items The value of var item=$("#sel option:selected").text(); //Get the text of the selected item in select var option_num=$('#sel').val(); // Get the Select project index $ ("#SEL") [0] .selectEdindex = 1; // The second element of the selecting drop -down box is the current selection value $ ("input [name = 'sexx sex ']").get(1).checked=true; //The second element of the radio radio selection group is the currently selected value
Or set the default selection for the radio button: $("input[name='sex']").each(function(){ if($(this).val()= =s){ $(this).attr("checked", true); 🎜>
Jquery sets the default selected item in the drop-down list (select) based on the value value