Got a problem with my home made accordion. Its probably being done in an inefficient way.
html and jQ is on jfiddle ^^
First problem: If you click one item then quickly click another, both will go blue when only the active should go blue, perhaps a problem with the way i've done the 'animate'.
Second problem Not very noticeable at the moment but on the page (maybe when with more content) it jerks near the end of the slide down, just not as smooth as it should be.
Code:
$(document).ready(function(){
$(".accordion").click(function () {
$('.acc-content', this).removeClass("na");
$('.na').slideUp("medium");
$('.acc-title', this).animate({"backgroundColor":"#00bff3"}, 1000);
$('.acc-title').css("backgroundColor", "#77787B");
$('.acc-content', this).slideToggle("medium");
$('.acc-content', this).addClass("na");
});
});
HTML
<div class="accordion">
<div class="acc-title">Test Title</div>
<div class="acc-content">Lorem ipsum dolor sit amet</div>
</div>
<div class="accordion">
<div class="acc-title">Test Title</div>
<div class="acc-content">Lorem ipsum dolor sit amet</div>
</div>
<div class="accordion">
<div class="acc-title">Test Title</div>
<div class="acc-content">Lorem ipsum dolor sit amet</div>
</div>
<div class="accordion">
<div class="acc-title">Test Title</div>
<div class="acc-content">Lorem ipsum dolor sit amet</div>
</div>
<div class="accordion">
<div class="acc-title">Test Title</div>
<div class="acc-content">Lorem ipsum dolor sit amet</div>
</div>