Javascript手风琴动作怪异

Javascript accordion acting weird

本文关键字:手风琴 Javascript      更新时间:2023-09-26

当我使用jsfiddle使用javascript创建一个简单的手风琴时,它工作得很好,但是当我在我的。aspx中使用相同的代码时,手风琴没有打开。我试着用IE调试,但没有用。任何指向这一点的指针都将大有帮助。

我的jsfiddle链接- jsfiddle代码

 var acc = document.getElementsByClassName("accordion");
    var i;
    for (i = 0; i < acc.length; i++) {
        acc[i].onclick = function () {
            this.classList.toggle("active");
            this.nextElementSibling.classList.toggle("show");
        }
    } 

和我的html:

 <div>
 <button class="accordion">
    Q1. Why does CMS collect patient-level
        data?</button>
<div class="panel">
    <p>
        Patient-level data with patient-level identifiers for
    the numerator and denominator of each measure allows CMS to match HEDIS data to
    other patient-level data for special projects of national interest and research,
    such as an assessment of whether certain groups (e.g., ethnic, racial, gender, geographic)
    are receiving fewer or more services than others. These analyses will not be used
    for public plan-to-plan comparisons.</p>
</div>
<button class="accordion">
    Q2. What procedures must I follow to submit
        patient-level data files?</button>
<div class="panel">
    <p>
        Plans need to create patient-level data file(s) 
    conforming to the 2010 Patient-Level Data File Specifications and upload files 
    to CMS via CMS’ Enterprise File Transfer (EFT) infrastructure using an existing 
    Gentran or Connect:Direct account. Alternatively, plans may use a third-party 
    vendor (e.g., Infocrossing) for data file submissions. In either case, the use 
    of Gentran or Connect:Direct is the approved method for patient-level data file 
    submissions.</p>
</div>
<button class="accordion">
    Q3. Where do I find the data file submission
        instructions?</button>
<div class="panel">
    <p>
        It is imperative that each organization confirm their ability to interface with 
    the CMS EFT infrastructure prior to attempting an upload. ior to attempting an upload.</p>
</div>
</div>

我关闭这个,因为我导入了jQuery UI库,并解决了它