0
HTML:我的手風琴似乎不起作用。點擊,但沒有發生。它沒有走通的JS
<div class="accordion">
<div class="accordion-section">
<a class="accordion-section-title" href="#accordion-1">Test</a>
<div class="accordion-section-content" id="accordion-1"></div>
</div>
</div>
我的JS(這是我從http://inspirationalpixels.com/tutorials/creating-an-accordion-with-html-css-jquery了):
jQuery(document).ready(function() {
function close_accordion_section() {
jQuery('.accordion .accordion-section-title').removeClass('active');
jQuery('.accordion .accordion-section-content').slideUp(300).removeClass('open');
}
jQuery('.accordion-section-title').click(function(e) {
// Grab current anchor value
var currentAttrValue = jQuery(this).attr('href');
if(jQuery(e.target).is('.active')) {
close_accordion_section();
}else {
close_accordion_section();
jQuery(this).addClass('active');
jQuery('.accordion ' + currentAttrValue).slideDown(300).addClass('open');
}
e.preventDefault();
});
});
嘗試把e.preventDefault();一開始,在currentAttrValue之前 –