我有這個工作完全像我想要的(見小提琴下面),除了我發現toggle()已被棄用。我想知道是否可以使用toggleClass()或hide()和show()來切換dropdownpanel的可見性。jQuery合併切換(),顯示()和隱藏()
$("#dropdown").click(function() {
$("#dropdownpanel").toggle();
});
$("#latinlink").click(function() {
$("#sometext").hide();
$("#latin").show();
});
$("#back").click(function() {
$("#latin").hide();
$("#sometext").show();
});
#dropdownpanel {
width: 236px;
height: 100vh;
background: rgba(00, 00, 00, 0.55);
color: #ffffff;
position: fixed;
top: 38px;
left: 0px;
display: none;
padding: 5px;
}
#latin {
width: 236px;
height: 100vh;
background: rgba(00, 00, 00, 0.55);
color: #ffffff;
position: fixed;
top: 38px;
left: 0px;
display: none;
padding: 5px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<button id="dropdown">
Dropdown
</button>
<div id="dropdownpanel">
<p id="sometext">Click
<a href="#" id="latinlink">here</a> to read some latin...
</p>
</div>
<div id="latin">
<button id="back">
Back
</button>
<br /> Lorem ipsum dolor sit amet, epicuri argumentum constituam eum ea. Munere aliquip te nec, at nec dicat fuisset offendit, quo an sonet honestatis. Tempor facete sadipscing te his. Nam vivendo postulant reprehendunt te, offendit principes pri ex, at causae
oblique torquatos pro.
<br />
<br /> Libris philosophia has eu, nam iriure alienum intellegam at. Nec appareat electram ne, amet nonumes per te. Usu eu nisl verterem, labore regione legimus in nam, vel saperet laboramus voluptatibus ut. Ad eam altera nemore. No nobis corpora pro, qui
ex tale suas dissentias, et iisque omittam inciderint sit. Usu ut case menandri vituperata.
</div>
我不明白你在問什麼。什麼_「它現在表現得像後退按鈕」_是什麼意思? – j08691