Ids in your DOM should be unique. It looks to me like you are trying to create several DIVs with the same id ('accordion').
If you want to have more than one you should use the class parameter.
So use $(".accordion")
instead of $("#accordion")
and <div class="accordion" style="padding:5px;">
instead of <div id="accordion" style="padding:5px;">