知っている。タイトルがちょっと……わかりにくかったです。あなたがそれを理解するのを助けるために私ができることを見ていきます。
基本的に、私が個人サイトのために行ったことは、Web ページの本体としてのメイン ナビゲーションです。リンクがクリックされると、次のような非表示のコンテンツが読み込まれます。
$(document).ready(function(){
$('li a#about-toggle').click(function(){
$('li#about').animate({"height": "toggle", "opacity": "toggle"}, "slow").toggleClass("hidden");
});
$('li a#portfolio-toggle').click(function(){
$('li#portfolio').animate({"height": "toggle", "opacity": "toggle"}, "slow").toggleClass("hidden");
});
$('li a#resume-toggle').click(function(){
$('li#resume').animate({"height": "toggle", "opacity": "toggle"}, "slow").toggleClass("hidden");
});
$('li a#contact-toggle').click(function(){
$('li#contactme').animate({"height": "toggle", "opacity": "toggle"}, "slow").toggleClass("hidden");
});
});
これにより、現在、Web サイトの訪問者はすべての要素を開くことができます。これは、視覚的に不快であるだけでなく、いくつかのバグを作成しますが、ほとんどの場合、視覚的に不快です.
私の質問は、私が可能な限り無傷のままにしているコードで、一度に 1 つしか開けないようにするにはどうすればよいですか?
前もって感謝します、ジェイコブ
編集:
$(document).ready(function(){
$('#about-toggle').click(function(){
$("li.active").addClass("hidden");
$('#about').animate({"height": "toggle", "opacity": "toggle"}, "slow").removeClass("hidden").addClass("active");
});
$('#portfolio-toggle').click(function(){
$("li.active").addClass("hidden");
$('#portfolio').animate({"height": "toggle", "opacity": "toggle"}, "slow").removeClass("hidden").addClass("active");
});
$('#resume-toggle').click(function(){
$("li.active").addClass("hidden");
$('#resume').animate({"height": "toggle", "opacity": "toggle"}, "slow").removeClass("hidden").addClass("active");
});
$('#contact-toggle').click(function(){
$("li.active").addClass("hidden");
$('li#contactme').animate({"height": "toggle", "opacity": "toggle"}, "slow").removeClass("hidden").addClass("active");
});
});