这是问卷开始时我的 HTML:
<form id="questionnaire">
Question 1: Do you like dogs?<br>
<input type="radio" name="answer" value="yes">Yes<br>
<input type-"radio" name="answer" value="no">No<br>
<input type="submit" value="Next Question" />
</form>
到目前为止,这是我的 Javascript:
$(document).ready(function(){
var q2 =
'Question 2: Do you like cats?
<input type="radio" name="answer" value="yes">Yes<br>
<input type-"radio" name="answer" value="no">No<br>
<input type="submit" value="Next Question" />'
$('#questionnaire').submit(function(){
$('#questionnaire').html(q2); // This puts the Question 2 HTML into the form
return false;
});
var q3 =
'Question 3: Do you like bunnies?
<input type="radio" name="answer" value="yes">Yes<br>
<input type-"radio" name="answer" value="no">No<br>
<input type="submit" value="Next Question" />'
});
我要编写什么样的函数,以便在问题 2 加载后,单击“下一个问题”按钮导致问题 3?