0
我正在嘗試創建單個選擇題。JQuery Multiple Choice
在下面的例子中,我想選項1和3是正確的答案。當點擊提交按鈕時,我只想運行一個如果陳述,看是否選中了選項1和3複選框,如果是,則切換正確1 div。否則,如果選項1和3是而不是選中,則切換錯誤1 div。
頭標記我會
<script type="text/javascript">
function toggleDiv2(divId) {
$("#"+divId).toggle("slow");
}
</script>
然後在身體我將有:
<div class="control-group">
<label class="control-label" for="optionsCheckboxList">Check your answers</label>
<div class="controls">
<label class="checkbox">
<input type="checkbox" id="option1" name="optionsCheckboxList1" value="option1">
<strong>Option One</strong> this is a correct answer. Select this one.
</label>
<label class="checkbox">
<input type="checkbox" id="option2" name="optionsCheckboxList2" value="option2">
<strong>Option two</strong> this is an incorrect answer. Do not select this one.
</label>
<label class="checkbox">
<input type="checkbox" id="option3" name="optionsCheckboxList3" value="option3">
<strong>Option three</strong> This is a correct answer. Select this one.
</label>
<p class="help-block"><strong>Hint:</strong> Add a hint if you would like. This is optional.</p>
<br>
<a href="javascript:toggleDiv2('correct1');" class="btn btn-primary">Submit</a>
<br><br>
<div id="correct1" class="alert alert-success" style="display: none">
Well Done! You correctly answered this question!
</div><!-- end correct1 -->
<div id="incorrect1" class="alert alert-error" style="display: none">
Oh snap! Please try again.
</div><!-- end incorrect1 -->
</div><!-- end control-group -->
不知道這是否事項或沒有,但這是頁面鏈接了jQuery於:
<script src="html/assets/js/jquery-ui-1_8_18custom/js/jquery-1.7.1.min.js" type="text/javascript"></script>
<script src="html/assets/js/jquery-ui-1_8_18custom/js/jquery-ui-1.8.18.custom.min.js" type="text/javascript" ></script>
你有一個不必要的