jquery手风琴不适用于href链接

时间:2014-09-21 04:15:40

标签: javascript jquery html accordion

我有一架手风琴但是在div中有链接标签的地方无法滑开。我正在使用jquery 1.11,这里有实时链接:santaclaratailgating.com/test(第一个FAQ手风琴无效):

<script type="text/javascript">
$(document).ready(function($) {
$('#accordion').find('.accordion-toggle').click(function(){

  //Expand or collapse this panel
  $(this).next().slideToggle('fast');

  //Hide the other panels
  $(".accordion-content").not($(this).next()).slideUp('fast');

});
});

 </script>
<style>
.accordion-toggle {cursor: pointer;}
 .accordion-content {display: none; font-size: 120%; font-weight: bold; color:#00458D;align:left;text-align:left; }
 .accordion-content.default {display: block;}
</style>


<div id="accordion">
<h4 class="accordion-toggle">accordion title</h4>
<div class="accordion-content">
<p>test <a href="hi.com">a</a>  </p>

</div>
<h4 class="accordion-toggle">accordion title2</h4>
<div class="accordion-content">
<p>works fine</p>
</div>
</div>

1 个答案:

答案 0 :(得分:1)

工作正常。

$(document).ready(function($) {
$('#accordion').find('.accordion-toggle').click(function(){

  //Expand or collapse this panel
  $(this).next().slideToggle('fast');

  //Hide the other panels
  $(".accordion-content").not($(this).next()).slideUp('fast');

});
});
.accordion-toggle {cursor: pointer;}
 .accordion-content {display: none; font-size: 120%; font-weight: bold; color:#00458D;align:left;text-align:left; }
 .accordion-content.default {display: block;}
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>

<div id="accordion">
<h4 class="accordion-toggle">accordion title</h4>
<div class="accordion-content">
<p>test <a href="hi.com">a</a>  </p>

</div>
<h4 class="accordion-toggle">accordion title2</h4>
<div class="accordion-content">
<p>works fine</p>
</div>
</div>