$("Get the selection value of the drop-down menu $("#testSelect option:selected").text(); $("# testSelect").find('option:selected').text(); $("#testSelect").val(); Select the drop-down box according to the value of option $('#testSelect ').val('111');
$("input[@type=radio][@ checked]").val();//Get the value of the selected item of the radio button (note that there is no space in the middle) $("input[@type=radio][@value=2]").attr( "checked",'checked');//Set the radio button value=2 to the selected state. (Note that there is no space in the middle) 3, checkbox: $("input[@type=checkbox ][@checked]").val();//Get the value of the first selected item in the checkbox $("input[@type=checkbox][@checked]").each(function( ){//Since multiple check boxes are generally selected, you can output in a loop alert($(this).val()); });
$("# chk1").attr("checked",'');//Unchecked $("#chk2").attr("checked",true);// Checked if($( "#chk1").attr('checked')==undefined){}//Determine whether it has been checked Of course jquery's selector is powerful. There are many methods.
jquery radio value, checkbox value, select value, radio selected, checkbox selected, select selected, and related to obtain the value of a group of radio selected items
$("# chk1").attr("checked",'');//Unchecked $("#chk2").attr("checked",true);// Checked if($( "#chk1").attr('checked')==undefined)//Determine whether it has been checked
Radio group radio: $("input[@type=radio]").attr("checked",'2');//Set the item with value=2 as the currently selected item Drop-down box select:
$("#sel"). attr("value",'-sel3');//Set the item with value=-sel3 as the currently selected item $("1111 2222").appendTo("#sel")//Add the option $("#sel").empty() of the drop-down box; // Clear the drop-down box
$("# chk1").attr("checked",'');//Unchecked $("#chk2").attr("checked",true);// Checked if($( "#chk1").attr('checked')==undefined)//Determine whether it has been checked
$("#sel ").attr("value",'-sel3');//Set the item with value=-sel3 as the currently selected item $("< ;option value='2'>2222").appendTo("#sel")//Add the option $("#sel").empty() of the drop-down box;//Clear the drop-down box Box
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn