I was trying to catch an event on body tag, for example this doesn't work as expected:
<head> <script type="text/javascript" src="js/jquery-1.3.2.min.js"></script> </head> <body onclick="alert('body!')"> <div id="one" onclick="alert('div!')" style="width:100px;height: 100px;border:1px solid gray;"> <!-- blank --> </div> <script> $('#one').trigger('click'); </script> </body> although this one works: <head> <script type="text/javascript" src="js/jquery-1.3.2.min.js"></script> </head> <body> <div onclick="alert('body!')"> <div id="one" onclick="alert('div!')" style="width: 100px;height:100px;border:1px solid gray;"> <!-- blank --> </div> </div> <script> $('#one').trigger('click'); </script> </body> it took me sometime to figure this out, ' cause it was not stated anywhere. Why - body tag is not considered as parent? On May 17, 2:49 am, Mike Nichols <nichols.mik...@gmail.com> wrote: > can you show some code that isn't working > > On May 16, 6:21 am, jayarjo <jaya...@gmail.com> wrote: > > > "New in jQuery 1.3: > > > All triggered events now bubble up the DOM tree. For example if you > > trigger an event on a paragraph then it will trigger on that element > > first, then on the parent element, and its parent, and so on up to the > > document. The event object will have a .target property equal to the > > original triggered element. You can prevent the bubbling by calling > > stopPropagation() or by returning false from your > > callback."http://docs.jquery.com/Events/trigger#eventdata > > > In other words triggered event should bubble up to it's parent > > container, should it? If yes, then I want to catch it on parents level > > and trigger it on another child of choice, and so on. But it doesn't > > seem to bubble... :( > > > Any help appreciated.