我有一个测验布局,从数据库中获取问题和答案。隐藏点击并显示另一个直到最后
我目前有一个下一个按钮来通过这些问题,但我想这样做,所以当选择一个答案时,它会转到下一个问题。
每个问题/答案集都有这个div,id是问题的ID。
<div class="question container center" id="1" style="display: none;">
<h1>Question</h1>
Answer
Answer
Answer
Answer
</div>
答案按钮看起来是这样的:
<a class="waves-effect waves-light btn-large blue-grey lighten-2 btn-width mcqtest">Answer</a>
使用当前Jquery的IM是这样的:
$('#2, #3, #4, #5, #6, #7, #8, #9, #10, #11, #12, #13, #14, #15, #16, #17, #18, #19, #20, #21, #22, #23, #24, #25 ').hide();
$('#next').click(function(){
//code
var curr = $(".question:visible");
var next = curr.next(".question");
next.show();
curr.hide();
if (!next.next(".question").length) {
$("button").attr('disabled', 'disabled');
$("button").text("End of Test");
}
});
重要的是,'id's不应该以数字开头。 – RRK
答案的元素类型是什么? –
答案只是风格的标签 – JohnyChew