Checkbox inside an anchor click behavior

前端 未结 4 752
逝去的感伤
逝去的感伤 2021-01-12 14:55

Consider following snippet:



    
        

        
4条回答
  •  被撕碎了的回忆
    2021-01-12 15:47

    I Know this question is over 5 years old, but I had the same issue recently and the work-around I found was to add an onclick function to the checkbox and in that function call event.stopImmediatePropagation().

    from w3schools: "The stopImmediatePropagation() method prevents other listeners of the same event from being called"

    ie...the anchor.

    function checkbox_onclick(event){
    event.stopImmediatePropagation(); 
    }
    

提交回复
热议问题