嗨在我的網站我有一個就業門戶頁面,我用jquery手風琴來打開和關閉工作posted.Here當我點擊更多的信息按鈕手風琴選項卡正在擴大,但再次點擊更多信息按鈕時,它不會關閉,只有第一個按鈕向下打開,其餘部分向上打開。這裏是我的代碼。Jquery Accordion選項卡不要關閉點擊按鈕
<div class="digitalmarketingassociate">
<span class="digit">Digital Marketing Associate</span>
<div class="applynow">Apply Now</div>
<div class="moreinfo accordion" >More Info</div>
<div class="panel">
<p class="jobdes">Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum</p>
</div>
</div>
<div class="juniorqaengineer">
<span class="digit">Junior QA Engineer</span>
<div class="applynow">Apply Now</div>
<div class="moreinfo accordion1">More Info</div>
<div class="panel">
<p class="jobdes">Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum</p>
</div>
</div>
<div class="junioriosdeveloper">
<span class="digit">Junior iOS Developer</span>
<div class="applynow">Apply Now</div>
<div class="moreinfo accordion2">More Info</div>
<div class="panel">
<p class="jobdes">Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum</p>
</div>
</div>
的Jquery:
所有的var acc = document.getElementsByClassName("accordion");
var i;
var currentActive;
var toggleAccordionState = function(accordion) {
accordion.classList.toggle("active");
accordion.nextElementSibling.classList.toggle("show");
};
for (i = 0; i < acc.length; i++) {
acc[i].onclick = function(){
if(currentActive) {
toggleAccordionState(currentActive);
}
toggleAccordionState(this);
currentActive = this;
}
}
var acc = document.getElementsByClassName("accordion1");
var i;
var currentActive;
var toggleAccordionState = function(accordion) {
accordion.classList.toggle("active");
accordion.nextElementSibling.classList.toggle("show");
};
for (i = 0; i < acc.length; i++) {
acc[i].onclick = function(){
if(currentActive) {
toggleAccordionState(currentActive);
}
toggleAccordionState(this);
currentActive = this;
}
}
var acc = document.getElementsByClassName("accordion2");
var i;
var currentActive;
var toggleAccordionState = function(accordion) {
accordion.classList.toggle("active");
accordion.nextElementSibling.classList.toggle("show");
};
for (i = 0; i < acc.length; i++) {
acc[i].onclick = function(){
if(currentActive) {
toggleAccordionState(currentActive);
}
toggleAccordionState(this);
currentActive = this;
}
}
任何一個誰可以幫助我提前致謝 – user7047368