I've obviously got a little bit of this code wrong but not sure where? So when I click .link
it toggles correctly, but when I click on the li it freaks out, hides the toggle and won't let click .link again show.
$(function() {
$('.link').click(function(event){
event.preventDefault();
$('#link' + $(this).attr('id')).toggle();
});
});
Here is my partial html for example
<li class="link" id="3"> <%= link_to "Kids" %></li>
<ul class="sub-link" id="link3">
<li> <%= link_to "Tops" %></li>
<li> <%= link_to "Trousers" %></li>
<li> <%= link_to "Shoes" %></li>
<li> <%= link_to "Coats" %></li>
</ul>
</ul>
or if you have a better way to perform this I'm all ears (I'm currently learning jQuery).