Я действительно спрашивал об этом раньше, однако я не получил то, что на самом деле хотел.
На мой старый топи c
Это для этого сайта: http://n-p-cain.com/schedule.html
Я буду sh , если вы нажмете кнопку «дата» в «разделе меню событий», чтобы перейти к этой дате в «списке событий», а также откроете аккордеон, теперь аккордеон останется закрытым (если я назову класс = «аккордеон» -link1 "или если вы нажмете кнопку в" меню событий ", откроется гармошка, но вы не перейдете к ней (если я воспользуюсь приведенным ниже кодом).
var acc = document.getElementsByClassName("accordion");
var i;
for (i = 0; i < acc.length; i++) {
acc[i].onclick = function() {
this.classList.toggle("active");
var panel = this.nextElementSibling;
if (panel.style.maxHeight){
panel.style.maxHeight = null;
} else {
panel.style.maxHeight = panel.scrollHeight + "px";
}
}
}
// get list of links by class
var links = document.getElementsByClassName("accordion-link");
var linksLength = links.length;
for(var i=0; i < linksLength; i++){
links[i].onclick = function(e){
// preventDefault is probably optional
// depending on your application
e.preventDefault();
// isolate the hash
var hash = e.target.hash;
// remove # from hash
hash = hash.substring(1, hash.length);
// select by id using hash
document.getElementById(hash).click();
}
}
@charset "utf-8";
/* CSS Document */
/* Style the buttons that are used to open and close the accordion panel */
button.accordion {
background-color: #020725;
color: #FFF;
font-weight: bolder;
cursor: pointer;
padding: 10px;
margin: 0px 5px 0px 5px;
width: 98%;
text-align: left;
border: none;
outline: none;
transition: 0.4s;
border-radius: 5px;
}
/* Add a background color to the button if it is clicked on (add the .active class with JS), and when you move the mouse over it (hover) */
button.accordion.active, button.accordion:hover {
background-color: #132437;
}
/* Style the accordion panel. Note: hidden by default */
div.panel {
padding: 1px;
margin-bottom: 5px;
background-color: #none;
max-height: 0px;
overflow: hidden;
transition: max-height 0.2s ease-out;
}
button.accordion:after {
content: '\02795'; /* Unicode character for "plus" sign (+) */
font-size: 13px;
color: #FFF;
font-weight: bolder;
float: right;
margin-left: 5px;
}
button.accordion.active:after {
content: "\2796"; /* Unicode character for "minus" sign (-) */
}
<div class="link_"><a href="schedule.html#0510i" class="accordion-link">2020.05.10</a></div><div class="link1">(日) littleHEARTS.大阪店</div>
<button class="accordion" id="0510i">5月10日 littleHEARTS.大阪店※時間未定</button>
<div class="panel"><div class="p">
※詳細発表になるまでは、店舗への問い合わせはご遠慮ください。
</div></div>