Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

clicking a child div

Status
Not open for further replies.

Agaaa

Technical User
May 15, 2008
1
PL
Please, could somebody help me?
I have divs and when clicking on a child div i would like to get just one onclick event, without that from the parent.
I checked on FF 2.0 and IE 6.0.
Code:
<html>
   <head>
      <script type="text/javascript">
            function stop(e) {
               if (!e) e = window.event;
               e.cancelBubble = true;
               if (e.stopPropagation) e.stopPropagation();
            }
      </script>
   </head>
   
   <body>
      <div onmouseover="this.style.border='2px solid blue';this.style.background='#FDE9B9';stop(event);"
                        onMouseOut="this.style.border=''; this.style.background=''; "
                        onclick="alert('1');stop(event)">
                        bbb
         <div onmouseover="this.style.border='2px solid blue';this.style.background='#FDE9B9';stop(event);"
                        onMouseOut="this.style.border=''; this.style.background=''; "
                        onclick="alert('2');stop(event)">
         aaa<BR>ccc
                       
         </div>
      </div>           
   </body>
</html>
 
hi,

so what exactly is the problem? it seems to work fine for me (i get only one alert when i click on aaa / ccc)...

Known is handfull, Unknown is worldfull
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top