0
我已經制作了此表單,當用戶從我的選擇表單中選擇「是」時,會顯示某些選項。我無法得到我隱藏的div來顯示,但我已經使用了控制檯,發現至少將select改爲yes確實會使我的if語句運行。我跑了一個測試和JQuery工作,但使用JQuery顯示帶有滑動和滑動的隱藏div
任何人都可以幫助我確定我要去哪裏錯了嗎?
<form method="post" action="quizcreatescript.php" name="quizcreateform" id="quizcreateform">
<select name="choosemarks" id="choosemarks">
<option value="noweights">No</option>
<option value="yesweights">Yes</option>
</select>
<!-- >This div is hidden until the user selects yes to add own marks<-->
<div class="hide" id="hiddendiv1"><!-- this select box will be hidden at first -->
<div class="input select">
<input type="text" name="quizcorrectaward" id="quizcorrectaward"><br>
<input type="text" name="quizincorrectaward" id="quizincorrectaward"><br>
</div>
</div>
<script type="text/javascript">
$("#choosemarks").change(function(){ // when #choosemarks changes
if ($(this).val() == "yesweights") { // if user selects to add own marks $(".hiddendiv1").slideDown("fast"); // if yes show the hidden div
}
else { $(".hiddendiv1").slideUp("fast"); //otherwise, hide the div again.
}
});
</script>
<input type="submit" name="createthequiz" id="createquiz" value="Create Quiz">
</form>
而CSS樣式有
.hide {
display:none;
}
請出示的例子在http://jsfiddle.net –