Jquery .bind events triggered when event capture or event bubble -


all, know in dom level 2 event model, there exists event capture , event bubble. can't figure out how jquery deal them. did experiment .bind method. here code .please review .

<script>     $(function() {         $('*').each(function(){             var current = this;             $(this).bind("dblclick",function(event){console.log('capture ' + current.tagname + '#'+ current.id +                     ' target ' + event.target.id);});          });     }); </script> <body id="greatgrandpa">     <div id="grandpa">         <div id="pops">             <img id="example" src="designer/templates/thumbnails/2colstemplate.png" />         </div>     </div> </body> 

the output looks below

capture img#example target example capture div#pops target example capture div#grandpa target example capture body#greatgrandpa target example capture html# target example 

when use event.stoppropagation(); event handler stop bubble dblclick event.

but have 2 questions . according logs writing order ,i guessed bind method make event triggered in event bubble(from bottom top of dom) not in event capature(from top of dom bottom). question is there possibility make event triggered in event capture period? thanks.

thanks.

jquery supports event bubbling phase, not event capture phase, not least because long time, ie didn't support capture. code showing bubbling, not capturing.

capture goes document down element on event occurred; bubbling starts on element , bubbles document again, why see events in order you've shown (which bubbling phase).


Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -