jQuery too much recursion

后端 未结 1 796
误落风尘
误落风尘 2020-12-29 03:18

Im trying to select a radio box when I click an LI. But i get the error \"to much recursion\".

Code is:

$(\'li\').click( function(){
     $(\'li.sele         


        
相关标签:
1条回答
  • 2020-12-29 03:29

    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.

    0 讨论(0)
提交回复
热议问题