Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8615021
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:16:07+00:00 2026-06-12T05:16:07+00:00

HTML <div> <span></span> <span></span> <span></span> <span></span> </div> jQuery $(‘div span’).on(‘click’, function(){ //direct – 1st

  • 0

HTML

<div>
 <span></span>
 <span></span>
 <span></span>
 <span></span>
</div>

jQuery

$('div span').on('click', function(){
  //direct - 1st method
});

$('div').on('click','span', function(){
  //delegation - 2nd method
});

I have used both above method in my code. I know second method is better due to it has only got single handler. My problems are:

  1. Is first method (direct) refers to the concept called event capturing? Is it an example for event capturing?
  2. Is second method (delegation) refers to the concept called event bubbling? Is it an example for event bubbling?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T05:16:09+00:00Added an answer on June 12, 2026 at 5:16 am
    $('div span').on('click', function(){
      //direct - 1st method
    });
    

    This event only attached the event handler to the spans inside Div that are currently present in the DOM.. i.e; if a new span element is added to the div , that span will not have a click event associated with it..

    The first and second one are example’s of Event Bubbling

    There comes the concept of Event delegation where in the ancestor is given the event handler and it is delegated to the children..

    The second example is an example of event delegation .
    Wherein event is attached to the parent element..So all the span element’s inside the div class are attached to the event handler ..

    So if a new span element is added to the div , becoz the event is associated with the span’s ancestor the event will fire in this case

    This helps in cases

    $('div').on('click','span', function(){
      //delegation - 2nd method
    });
    

    I have no idea where event capturing is used in the jQuery library

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is the html I have: <div id=social> <a href=# class=twitter><span class=text>Twitter</span></a> </div> What
If I have the HTML below: <div style=display:none;> <span id=hello>Hey</span> </div> And I do
I have some html snippet <div id=title>This is title<span id=close>X<span><div> The width of this
I have the following html markup: <div class=wrap_select> <span class=select id=selectdateRange>Today, 25 March, Sun</span>
I have this simple html: <div class=wrapper> <span class=higher> [higher] <span class=lower> hello </span>
I have the following html : <div class=mainmenu> <ul class=blue> <li class=><a href=tst/ id=a1_up><span
I have an HTML table like: <div> <table border=1> <thead> <tr class=example> <th> <span
I have a html page as below: <div id=test1> <table> <tr> <td><span id=234>ABKO</span></td> </tr>
jQuery $(div span[z*='w']:last-child).css({color: red}); and the html <div> <span z=ww>Sam</span> <!-- Didn't works -->
I have the following html (i'm also using Jquery and JqueryUI) <div style=display:none; position:fixed;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.