<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title> 获取被选中的radio值</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<script src="js/jquery-1.7.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function(){
$("#test").click(function(){
$(":input[type='checkbox']:checked").each(function(){ //获取被选中的checkbox的value值
alert($(this).val());
})
var docTemp=document.thisform.checkbox;
for (i=0;i <docTemp.length;i++){
if(docTemp[i].checked){
strText=docTemp[i].nextSibling.nodeValue; // 获取被选中的checkbox的文本值
alert(strText);
}
}
alert($(":radio:checked + span").text()); //获取被选中的radio 文本值
alert($(":input[type='radio']:checked").val()); //获取被选中的radio value值
alert($("#select_id").val()); // 获取被选中的 select的value值
alert($("#select_id").find("option:selected").text()); // 获取被选中的 select的文本值
})
})
</script>
</head>
<body>
<form name="thisform" method="post">
你爱国吗: <input type="radio" name="radio1" class="rd" id="rd" value="1"/>
<span>a</span>
<input type="radio" name="radio1"class="rd" id="tt" value="2" />
<span>b</span>
<input type="radio"name="radio1"class="rd" value="3"/>
<span>c</span>
<ul id="options" class="options">
<li><label for="opA" ><input type="checkbox" name="checkbox" id="opA" value="1"/>选项A</label></li>
<li><label for="opB" ><input type="checkbox" name="checkbox" id="opB" value="2" />选项B</label></li>
<li><label for="opC" ><input type="checkbox" name="checkbox" id="opC" value="3"/>选项C</label></li>
<li><label for="opD" id="op"><input type="checkbox" name="checkbox" id="opD" value="4"/>选项D</label></li>
</ul>
<select id="select_id">
<option value="111">aa</option>
<option value="222">bb</option>
<option value="333">cc</option>
</select>
<input type="button" value="test" id="test"/>
</form>
</body>
</html>