2

How do we do event capturing in Jquery. I know all about event bubbling and event capturing in JavaScript but interested to know if Jquery has something similar for event capturing. If not, then how can I extend Jquery code for this additional functionality. Please guide. Thanks in adv.

Raj
  • 570
  • 5
  • 15
  • What do you mean by "stop event capturing"? Unregister all capturing event handlers? Convert them to bubbling ones? Or do you mean how to actually **do** capturing event handlers? – Siguza Jun 27 '15 at 18:18
  • For your reference, I've created a [JS Fiddle](https://jsfiddle.net/rajkishoreworks/ptv4ajp8/) . This is a simple demonstration of event capturing done via JS. I simply wanted to do this by Jquery. I wanted to know jsfiddle code line `divs[i].addEventListener("click", highlightThis, true)` alternative in jquery – Raj Jun 27 '15 at 18:39
  • Yes, I know what capturing is. But how did the word "stop" find its way into your question? Because how can you stop something that isn't even there? – Siguza Jun 27 '15 at 18:43
  • @Siguza Thanks for correcting me on my query. See! I updated my Question. Now can you please suggest something on regrading my previous comment and updated Question. – Raj Jun 27 '15 at 18:49
  • 1
    Before you go off extending jQuery, you might wanna have a look at [this question](http://stackoverflow.com/q/7163616/2302862). There's a reason jQuery doesn't support capturing. – Siguza Jun 27 '15 at 19:00
  • @Siguza Thanks! for this useful link. I appreciate. – Raj Jun 28 '15 at 06:59
  • @Siguza Can you please give me some hints that if they implement event capturing phase in jquery then what kind of issues may arise. – Raj Jun 29 '15 at 10:01
  • Some browsers simply don't support it, namely IE < 9. – Siguza Jun 29 '15 at 10:09

2 Answers2

1

jQuery events works with event bubbling and it doesn't support capturing. So, there's no sense to stop event capturing.

See this and this for more information.

Community
  • 1
  • 1
Bhojendra Rauniyar
  • 83,432
  • 35
  • 168
  • 231
  • I had guessed it already. Thats why i highlighted the line in my query **If not, then how can I extend Jquery code for this additional functionality** . My area of interest is to know how would i add event capturing phase in jquery if it doesn't have. Hope there must be a way. – Raj Jun 27 '15 at 18:27
  • Then you need to write your own library to extend the ability for capturing events. – Bhojendra Rauniyar Jun 27 '15 at 18:35
0

I found the comment Event Capturing in Jquery upto my satisfaction. Hence closing this question.

Community
  • 1
  • 1
Raj
  • 570
  • 5
  • 15