包裝你的文本框用一個div,說 「thisWrapper」
<div id="thisWrapper">
<input type="checkbox" id="check-1" class="checkchoice staff" required><label for="check-1" class="choice staff">Staff</label>
<input type="checkbox" id="check-2" class="checkchoice student" required><label for="check-2" class="choice student">Student</label>
</div>
,並在更改事件你貼地址:
$("thisWrapper").hide();
應該立即隱藏兩個複選框。當然,你必須添加一個「取消」或「重置」按鈕來再次顯示覆選框。
,或者你可以給複選框都喜歡 「mycheckboxes」 新的班級名稱,並呼籲這一點:
$(".mycheckboxes").click(function() {
$('#check-1').hide();
$("#check-2").hide();
});
*這裏「S上的完整的例子我有WORKING在Fiddler的**
試試這個:
<div id="thisWrapper">
<input type="checkbox" id="check-1" class="checkchoice" required><label for="check-1" class="choice staff">Staff</label>
<input type="checkbox" id="check-2" class="checkchoice" required><label for="check-2" class="choice student">Student</label>
</div>
<div id="nameinput">
<input type="text" placeholder="So what's your name?" />
</div>
<script>
$(function() {
$(".checkchoice").change(function() {
$("#thisWrapper").hide();
$("#nameinput").show();
});
});
</script>
你爲什麼隱藏*雙向*? – 2013-02-14 01:59:57
您隱藏了複選框,但沒有隱藏標籤。 (這是你問什麼?) – bfavaretto 2013-02-14 02:00:52
試圖隱藏 – Modelesq 2013-02-14 02:11:04