Handle Onclick event on different DIV tags - Javascript DOM Event

Javascript examples for DOM Event:onclick

Description

Handle Onclick event on different DIV tags

Demo Code

ResultView the demo in separate window

<html>
   <head></head>
   <body> 
      <script type="text/javascript">
function manualToggle(val)/*  w ww .  j av  a  2 s  .  c  om*/
{
    console.log(val.id);
}

      </script> 
      <div id="test" onclick="manualToggle(this);"> 
         <span>Allowed to click</span> 
         <span onclick="event.cancelBubble=true;if (event.stopPropagation) event.stopPropagation();">Not allowed to click</span> 
         <span>Allowed to click</span> 
      </div>  
   </body>
</html>

Related Tutorials