When I press mainDiv, the mainDiv() function is mainDiv() , when I press subDiv, the mainDiv() and subDiv() functions are mainDiv() .
I want to call only the subDiv() function when I press subDiv. How can I achieve this?
CODE:
<div onclick="mainDiv()"> show main div <div onclick="subDiv()"> show sub div </div> </div> <script type="text/javascript"> function mainDiv(){ alert("main div is clicked"); } function subDiv(){ alert("sub div is clicked"); } </script>
source share