現在、この関数は表示されているすべての回答を非表示にしています。2 回目にクリックされた特定の質問に属する回答のみを非表示にする必要があります。私はJQueryに非常に慣れていないので、おそらくこれに対する簡単な解決策がありますが、どんな助けも素晴らしいでしょう.
$(document).ready(function() {
$(".question").click(function () {
$('.answer').hide(); // hides open answers before showing a new answer
if ($(this).next().is(":hidden")) { // check the visibility of the next element in the DOM
$(this).next().show(); // show it
} else {
$(this).next().hide(); // hide it
}
});
});