HTML lists with jQuery for mobile devices

Recently I had to transform a group of li elements into an accordion for a mobile version of a client website. So this is what I came up with. I had an html that looked like this <ul> <li><span>Category1</span> <ul> <li>Subcategory1</li> <li>Subcategory2</li> </ul> </li> <li><span>Category2</span> <ul> <li>Subcategory</li> <li>Subcategory1</li> </ul> </li>   </ul> And I wanted [...]