Click on a div to toggle a checkbox inside of it using javascript

前端 未结 6 899
耶瑟儿~
耶瑟儿~ 2020-12-15 18:50

This seems to be a simple problem, but I dont use alot of javascript.

I have a div, with a checkbox in it, and would like the whole div to toggle the checkbox. This

6条回答
  •  醉话见心
    2020-12-15 19:22

    onclick="if (event.target.tagName != 'INPUT') document.getElementById('cb').checked = !document.getElementById('cb').checked"
    

提交回复
热议问题