Bug Tracker


Opened 10 years ago

Closed 8 years ago

#944 closed enhancement (fixed)

$().trigger + event propogation

Reported by: anonymous Owned by:
Priority: minor Milestone:
Component: event Version:
Keywords: event trigger propogation Cc:
Blocked by: Blocking:

Description (last modified by joern)

Test case:

<div><span><a href="#">test link</a></span></div>

<script type="text/javascript">
$('div, a')
    .bind('click', function(e){
        alert('current: '+ this.nodeName +', target: '+ e.target.nodeName);



current: A, target: A

Expected result:

current: A, target: A
current: DIV, target: A

Change History (5)

comment:1 Changed 10 years ago by brandon

  • need set to Review

Perhaps this could be done by creating a "propagate" method that if the event wasn't stopped the method would search the parents for handlers of the same type. It could be done but perhaps best done via a plugin and might turn out to be too slow.

comment:2 Changed 9 years ago by flesler

Ok, the demo says: $('div, a') not $('div a'). Note the comma. I assume that's a typo ?

This is solved with event delegation, instead of $('div a')

use $('div').click(function(e){

if( e.target.nodeName == 'A' )



comment:3 Changed 9 years ago by joern

  • Description modified (diff)

Ariel, it doesn't look like its a typo. To make it more clear:

<div><span><a href="#">test link</a></span></div>
<script type="text/javascript">
$('div').bind('click', function(e){
        alert('current: '+ this.nodeName +', target: '+ e.target.nodeName);

So this is about event bubbling for custom events, which isn't implemented. I agree with Brandon that a plugin implementation would be helpful for a start.

comment:4 Changed 9 years ago by flesler

Hi Jorn, there is a plugin, it's called Bubble: http://plugins.jquery.com/project/Bubble

comment:5 Changed 8 years ago by dmethvin

  • Resolution set to fixed
  • Status changed from new to closed

Works as desired in jQuery 1.3!

Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

Modify Ticket

Change Properties

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.