HTML代码 复制代码 代码如下: 1 2 3 4 通过Type获得RadioButtonList的Value A B C D 通过Name获得Radio的Value A B C D 通过Name获得CheckBox的Value 全选 反选 A1 A2 A3 A4 获得Multiple的Value 添加 移除 B1 B2 B3 B4 获得Select的Value 添加 移除 jQuery代码 复制代码 代码如下: <BR>$(document).ready(function () { <BR>//获得RadioButtonList的Value <BR>$("#btnGetRadioButtonListValue").click(function () { <BR>if ($("input[type=radio]:checked").val() == null) { <BR>alert("请选择"); <BR>return false; <BR>} <BR>alert($("input[type=radio]:checked").val()); <BR>}); <BR>//获得Html的Radio的Value <BR>$("#btnGetRadioValue").click(function () { <BR>if ($("input[name='radioSelect']:checked").val() == null) { <BR>alert("请选择"); <BR>return false; <BR>} <BR>alert($("input[name='radioSelect']:checked").val()); <BR>}); <BR>//获得CheckBox的Value <BR>$("#btnGetCheckBoxValue").click(function () { <BR>var values = ""; <BR>$("input[name='chkSelect']").each(function () { <BR>if ($(this).attr("checked")) { <BR>values += $(this).val() + ","; <BR>} <BR>}); <BR>if (values == "") { <BR>alert("请选择"); <BR>return false; <BR>} <BR>values = values.substring(0, values.length - 1); //去掉尾部, <BR>alert(values); <BR>}); <BR>//全选 <BR>$("#btnSelectAllOn").click(function () { <BR>$("input[name='chkSelect']").each(function () { <BR>$(this).attr("checked", true); <BR>}); <BR>}); <BR>//返选 <BR>$("#btnSelectAllOff").click(function () { <BR>$("input[name='chkSelect']").each(function () { <BR>$(this).attr("checked", false); <BR>}); <BR>}); <BR>//获得Multiple的值 <BR>$("#btnGetMultipleValue").click(function () { <BR>var values = ""; <BR>$("#multiple1 option:selected").each(function () { <BR>values += $(this).val() + ","; <BR>}) <BR>values = values.substring(0, values.length - 1); //去掉尾部, <BR>alert(values); <BR>}); <BR>//添加Multiple的Option <BR>$("#btnAddMultipleOption").click(function () { <BR>$("#multiple1").append("<option value='AX'>AX"); <BR>}); <BR>//移除Multiple所选Option <BR>$("#btnRemoveMultipleOption").click(function () { <BR>$("#multiple1 option").remove("option:selected"); <BR>}); <BR>//获得Select的值 <BR>$("#btnGetSelectValue").click(function () { <BR>alert($("#select1 option:selected").val()); <BR>}); <BR>//添加Select的Option <BR>$("#btnAddSelectOption").click(function () { <BR>$("#select1").append("<option value='BX'>BX"); <BR>}); <BR>//移除Select所选Option <BR>$("#btnRemoveSelectOption").click(function () { <BR>$("#select1 option").remove("option:selected"); <BR>}); <BR>}); <BR>