0
以前の質問に応じて、質問と回答のクイズを作成しようとしています。したがって、ユーザーが「はい」をクリックすると、前の質問が画面から消え、新しい質問が画面に表示されます。何もクリックされていなければ、別の質問が表示されます。どんな助けも大歓迎です。ありがとうございました。以前の質問による多レベルの回答
コード:
<!DOCTYPE html>
<html>
<body>
<p>Is the answer to this question Yes or No?</p>
<button onclick="myFunction1()">Yes</button>
<button onclick="myFunction2()">No</button>
<p id="demo"></p>
<script>
function myFunction1() {
}
function myFunction1() {
}
</script>
</body>
</html>
これは私が探しているものとまったく同じように見えますが、何5つのレベルの質問が必要な場合はどうすればいいですか?質問の数は2^n(nはレベル)になりますか? – sphe2011
まあ...多くのdiv要素を持ち、多くのidを持つでしょう。 idをパラメータで送信することで、js関数を1つだけ使用できます。 – AntoineCa
function myFunction3(){ \t document.getElementById( "first-question")。style.display = "none"; \t document.getElementById( "second-question-2")。style.display = "none"; document.getElementById( "three-question-1")。style.display = "block"; } まだ2番目の質問が表示されます。 – sphe2011