So I have this code and it generates the first 9 of the accordions, however will not go past 9.
<script>
$(function() {
$('#accordion1,#accordion2,#accordion3,#accordion4,#accordion5,#accordion6,#accordion7,#accordion8,#accordion9,#accordion10,#accordion11,#accordion12,#accordion13,#accordion14,#accordion15,#accordion16,#accordion17,#accordion18,#accordion19,#accordion20').accordion();
});
</script>
Any ideas why? And yes I know the code is a mess and I could do (i++ etc..) but leaving as it is for now 🙂
Oh yeah sorry :S
So I have a script that generates the id #1….#20 for the div.
<script>
var i = 01;
$('.accordion').each(function(i){
$(this).attr('id', 'accordion'+(i+1));
});
</script>";
Then on the actual div itself I have
<div id='' class='accordion'>
..............</div>
Thanks James
Since you already have a class to all the elements you want, why don’t you use that to target the accordions ?
(additionally, in you code the
var i = 01;is useless. You only use theiparameter of the function)