25 2月 2014

实习笔记Jquery之checkbox的显示与隐藏

<head>
<!–Jquery checkbox事件创建隐藏–>
<script type=”text/javascript” src=”./jquery-1.4.2.min.js”></script>
<script type=”text/javascript”>
$(function () {
// 选择”有”
$(“#allergy_1”).bind(“click”, function () {
$(“input[name=’allergy_drug’]”).attr(“disabled”,false);
});
});

$(function () {
// 选择”无”
$(“#allergy_0”).bind(“click”, function () {
$(“input[name=’allergy_drug’]”).attr(“disabled”,true);
});
});

</script>
</head>

<tr>
<td><strong>药物过敏史</strong>
<label>
<input type=”radio” name=”allergy” value=”无” id=”allergy_0″>
无</label>
<label>
<input type=”radio” name=”allergy” value=”有” id=”allergy_1″>
有</label>
<label>
<input type=”checkbox” name=”allergy_drug” value=”青霉素” id=”allergy_drug_0″>
青霉素</label>
<label>
<input type=”checkbox” name=”allergy_drug” value=”磺胺” id=”allergy_drug_1″>
磺胺</label>
<label>
<input type=”checkbox” name=”allergy_drug” value=”链霉素” id=”allergy_drug_2″>
链霉素</label>
<label>
<input type=”checkbox” name=”allergy_drug” value=”其他” id=”allergy_drug_3″>
其他</label>
<label for=”allery_other”></label>
<input type=”text” name=”allery_other” id=”allery_other”></td>
</tr>

Only 1 comment

  1. 写的挺不错的 谢谢博主分享