jQuery too much recursion
Yes, it's event bubbling. Event bubbles up to li
You just have to do this:
$('li').click( function(e){
if($(e.target).is('li')){
$('li.selected').removeClass('selected');
$(this).addClass('selected');
$(this).children("input[type=radio]").click();
}
});
Don't add more events below, it's messy
when you .click() the child input
, the event bubbles up and re-triggers the li
's click(). You need to add a .click() to the input
and do event.preventBubble=true;
in it, or else just set the checked property instead of click()
ing it.