日期:2014-05-18  浏览次数:20445 次

求会javascript的高手编写的代码
例如选择地区时 需要选择河北省的时候,将所有河北省下属市区全部选中。有没有会用javascript代码写的方法

------解决方案--------------------
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
var che = $('#Checkbox1');
che.click(function () {
if (che.attr("checked") == true) {
$('input[name="a"]').attr("checked",true);
}
else {
$('input[name="a"]').attr("checked",false);
}
});
});
</script>
</head>
<body>
<table>
<tr>
<td colspan="2">
<input id="Checkbox1" type="checkbox" value="0" />陕西
</td>
</tr>
<tr>
<td>
</td>
<td>
<input id="Checkbox9" name="a" type="checkbox" value="1" />西安
<input id="Checkbox2" name="a" type="checkbox" value="2" />咸阳
<input id="Checkbox3" name="a" type="checkbox" value="3" />宝鸡
<input id="Checkbox4" name="a" type="checkbox" value="4" />榆林
<input id="Checkbox5" name="a" type="checkbox" value="5" />渭南
</td>
</tr>
</table>
</body>
</html>