+ 7
How to prevent parents onclick event when its child is clicked?
In the example below, I have a div element which contains button element. When i click on the div, divFunction() is called, but when i click on the button, buttonFunction() AND divFunction() are called. How do I prevent this, if I want only buttonFuction() to be called when i click on the button. I think, this problem has some elegant solutions using jQuery, but i havent started learning jQuery yet, so i would rather use only pure JavaScript. https://code.sololearn.com/WJUKzE09HwIG/?ref=app
2 ответов
+ 10
https://code.sololearn.com/W5iATFX0sZ8N/?ref=app
+ 5
Thanks a lot.