Javascript手风琴表现得很奇怪

时间:2016-10-18 19:31:01

标签: javascript

当我使用jsfiddle使用javascript创建一个简单的手风琴时,它工作正常,但当我在我的.aspx中使用相同的代码时,手风琴没有打开。我尝试使用IE进行调试,但没有用。任何指向这个的指针都会非常有用。

我与jsfiddle的链接 - jsfiddle code

 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>

1 个答案:

答案 0 :(得分:0)

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