Reputation: 203
I have an accordion on my page which works in FF, Chrome, Safari and IE10 but the accordion does not work in IE9, IE8, IE7 and IE6. What could be causing the problem?
Here's my Fiddle: http://jsfiddle.net/572zA/
Here's my code:
JS:
<script>
$(document).ready(function () {
$('#question > li > a').click(function () {
if (!$(this).hasClass('active')) {
$('#question>li>ul').slideUp();
$(this).next().slideToggle();
$('#question>li>a').removeClass('active');
$(this).addClass('active');
} else {
$('#question>li>ul').slideUp();
$('#question>li>a').removeClass('active');
}
});
});
</script>
HTML:
<ul id="question">
<li><a href="#!">Question 1</a>
<ul>
<li><a href="#!">Answer to question 1 goes here.</a></li>
</ul>
</li>
<li><a href="#!">Question 2</a>
<ul>
<li><a href="#!">Answer to question 2 goes here.</a></li>
</ul>
</li>
</ul>
Upvotes: 1
Views: 46
Reputation: 40096
Any reason not to use jQueryUI's accordion widget? Your code is reduced to:
$( "#question" ).accordion();
By the way, a big factor in using jQueryUI's accordion widget is that it is certified cross-browser compatible.
Upvotes: 2