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 8590001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:11:34+00:00 2026-06-11T23:11:34+00:00

I was wondering why some Javascript of mine would not work until I figured

  • 0

I was wondering why some Javascript of mine would not work until I figured that the audio events did not bubble up the DOM tree, e.g. the timeupdate-event.

Is there a rationale for not letting the events of the audio- and video-tag bubble?

  • 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-11T23:11:35+00:00Added an answer on June 11, 2026 at 11:11 pm

    The reason why event bubbling exists is solve the ambiguous question of which element is the intended target of the event. So, if you click on a div, did you mean to click the div, or its parent? If the child doesn’t have a click handler attached, then it checks the parent, and so on. I’m sure you know how that works.

    The reason why audio events don’t bubble is because they don’t make sense on any other element. There’s no ambiguity when you trigger a timeupdate on an audio element whether it’s meant for the audio element itself or its parent div, so there’s no need to bubble it.

    You can read a fuller history of event bubbling here

    Event delegation

    Event delegation is still possible by utilizing the capturing phase of the event. Simply add true as the third argument for addEventListener which looks like this:

    document.addEventListener('play', function(e){
        //e.target: audio/video element
    }, true);
    

    Note, that this event doesn’t bubble, but goes down the DOM-tree and can’t be stopped with stopPropagation.

    In case you want to use this with the jQuery’s .on/.off methods (for example to have namespacing and other jQuery event extensions). The following function, taken form the webshim library, should become usefull:

    $.createEventCapturing = (function () {
        var special = $.event.special;
        return function (names) {
            if (!document.addEventListener) {
                return;
            }
            if (typeof names == 'string') {
                names = [names];
            }
            $.each(names, function (i, name) {
                var handler = function (e) {
                    e = $.event.fix(e);
    
                    return $.event.dispatch.call(this, e);
                };
                special[name] = special[name] || {};
                if (special[name].setup || special[name].teardown) {
                    return;
                }
                $.extend(special[name], {
                    setup: function () {
                        this.addEventListener(name, handler, true);
                    },
                    teardown: function () {
                        this.removeEventListener(name, handler, true);
                    }
                });
            });
        };
    })();
    

    Usage:

    $.createEventCapturing(['play', 'pause']);
    
    $(document).on('play', function(e){
        $('audio, video').not(e.target).each(function(){
            this.pause();
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

wondering if some of you know what javascript framework facebook is using ? Thanks
I'm working on games using javascript some html and css, and I was wondering
I have custom JSP tags that generate some HTML content, along with some javascript
i'm doing some javascript coding and I was wondering if the length method is
I've seen this hovering around some javascript for a while now and was wondering
I have some working Javascript code that generates an RDF/XML document using variables picked
I was wondering if someone could help me with some javascript as I'm quite
I was wondering is there any clear advantage of setting some cookie though JavaScript
greetings all i was wondering if it's possible to send some javaScript code in
I have some JavaScript that is sharing a request between two separate servers on

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.