我也希望能够根据已链接的锚链接来打开手风琴。
即https://www.brighthouse.co.uk/what-document-to-upload#uk-visa
将打开#uk-visa手风琴。
谢谢
...代码
<button class="accordion" id="uk-visa">UK Visa</button><br>
<div class="panel">
<br>
<ul>
<li>Your Name</li>
<li>Date must valid (in date)</li>
</ul>
<img src="https://www.brighthouse.co.uk/-/media/images/document-upload/uk-visa.jpg" alt="working tax or child tax credit document" style="max-width:400px !important;">
</div>
<script>
var acc = document.getElementsByClassName("accordion");
var i;
for (i = 0; i < acc.length; i++) {
acc[i].addEventListener("click", function() {
this.classList.toggle("active");
var panel = this.nextElementSibling;
if (panel.style.maxHeight){
panel.style.maxHeight = null;
} else {
panel.style.maxHeight = panel.scrollHeight + "px";
}
});
}
</script>