[thelist] Trapping JS events

Chris Evans chris at unhappyfun.com
Wed Jul 2 14:27:29 CDT 2003


I have a div that contains a form element. Both have onMouseDown 
handlers.  When I click on the form element, both handlers get fired, 
first the form element handler, then the containing DIV handler.

Here is a code snippet :

<div id="myContainer" onmousedown="alert('Second Event')">
     <input type="text" value="" id="myFormField" 
onmousedown="alert('First Event');>
</div>

When I click on the input box, I get an alert for First Event, then one 
for Second Event.   Is there a way I can have the form element event 
handler trap the mouse click so that the containing DIV event handler 
doesn't get called?

Thanks,
Chris Evans
http://www.fuseware.com



More information about the thelist mailing list