var thepanels=$('#layout_west_accordion').accordion('panels');while(thepanels.length){ $('#layout_west_accordion').accordion('remove', 0);}