此時此功能隱藏所有顯示的答案。我需要它只隱藏屬於第二次點擊的特定問題的答案。我對JQuery非常陌生,所以可能有一個簡單的解決方案,但任何幫助都會很棒。只需要隱藏特定的'.answer'當任務。再次點擊該答案
$(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
}
});
});
請過帳html。這將有助於! –
把html也放在這裏或創建jsfiddle – rahularyansharma
所以你需要每個問題的計數器!並且您必須將其存儲爲檢查問題的標誌。如果計數器> 1隱藏....這樣的東西http://forum.jquery.com/topic/how-to-make-a-button-disabled-after-3-clicks – zod