日期:2014-05-20  浏览次数:20738 次

怎么取checkbox下label中的值
<input type="checkbox"  checked name="co" value="01" id="co1"/><label for="co1">私营企业</label>
<input type="checkbox"  name="co" value="02" id="co2"/><label for="co2">个体</label>            


怎么取到 私营企业 ?
------解决方案--------------------
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js">
</script>
<script>
$(document).ready(function(){
$("input[name='co'][checked]").next().html();
});
</script>
</head>
<body>
 
 
<input type="checkbox"  checked name="co" value="01" id="co1"/><label for="co1">私营企业</label>
<input type="checkbox"  name="co" value="02" id="co2"/><label for="co2">个体</label> 
 
</body>
</html>

------解决方案--------------------
给你个思路:你可以将label和checkbox绑定。(浏览器默认点击label触发checkbox点击事件)
<input type="checkbox" id="pageUD2" onclick="">&nbsp;<label for="pageUD2">推广单元</label>
------解决方案--------------------
引用:
Quote: 引用:

楼主问题都没问清楚你这个是在页面中取值还是抓取来的内容取值

用js拿到选中的checkbox下的label值 


<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js">
</script>
<script>
$(document).ready(function(){
var html=$("input:checked").nextAll("label").html();
alert(html);
});
</script>
</head>
<body>
 
 
<input type="checkbox"   name="co" value="01" id="co1"/><label for="co1">私营企业</label>
<input type="checkbox"  checked name="co" value="02" id="co2"/><label for="co2">个体</label> 
 
</body>
</html>