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

  • SEARCH
  • Home
  • 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 6834741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:08:57+00:00 2026-05-26T23:08:57+00:00

This is a code with jQuery 1.7: <div class=test> <div class=bu> <a> bu here

  • 0

This is a code with jQuery 1.7:

<div class="test">
  <div class="bu">
    <a>
      bu here
    </a>
  </div>
</div>
<script src="http://code.jquery.com/jquery-1.7.js"></script>
<script>
$(document).on('click', '.test', function () { alert(0); return false; });
$(document).on('click', '.bu', function () { alert(1); return false; });
$(document).on('click', '.bu', function () { alert(2); return false; });
</script>

Xlicking on .test > .bu will alert “1” and alert “2”, but not alerts “0”

My question is: how to do the same WITHOUT jQuery (on native DOM API)? Seems, I can’t do it with Native DOM API without implementing my own library…

  • 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-05-26T23:08:58+00:00Added an answer on May 26, 2026 at 11:08 pm
    <div class="a">
        <div class="b">
          <div class="c" style="border: 1px solid silver; width: 80px; text-align: center;line-height: 80px;">
              click me!
          </div>
        </div>
    </div>
    
    <script>
    
    // Element.prototype.matchesSelector
    (function (x) {
      var i;
      if (!x.matchesSelector) {
        for (i in x) {
          if (/^\S+MatchesSelector$/.test(i)) {
            x.matchesSelector = x[i];
            break;
          }
        }
      }
    }(Element.prototype));
    
    Document.prototype.on =
    Element.prototype.on = function (eventType, selector, handler) {
      this.addEventListener(eventType, function listener(event) {
        var t = event.target,
          type = event.type,
          x = [];
        if (event.detail && event.detail.selector === selector && event.detail.handler === handler) {
          return this.removeEventListener(type, listener, true);
        }
        while (t) {
          if (t.matchesSelector && t.matchesSelector(selector)) {
            t.addEventListener(type, handler, false);
            x.push(t);
          }
          t = t.parentNode;
        }
        setTimeout(function () {
          var i = x.length - 1;
          while (i >= 0) {
            x[i].removeEventListener(type, handler, false);
            i -= 1;
          }
        }, 0);
      }, true);
    };
    
    Document.prototype.off =
    Element.prototype.off = function (eventType, selector, handler) {
      var event = document.createEvent('CustomEvent');
      event.initCustomEvent(eventType, false, false, {selector: selector, handler: handler});
      this.dispatchEvent(event);
    };
    
    document.on('click', '.b', function () {
      alert(2);
    });
    document.on('click', '.a', function () {
      alert(1);
    });
    document.on('click', '.b', function (event) {
      alert(3);
      event.stopPropagation();
    });
    
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

On document ready I run this code: jQuery(document).ready(function(){ jQuery('#button').click(function() { jQuery('#contact_form').load(/Users/mge/Downloads/jquery-ajax-1/readme.txt); return false; });
I have this code: <script src=https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js></script> <style type=text/css> .kat1 { background-image:url(ikoniceKategorije/07.jpg); width:30px; height:30px; float:left;
Say I have jquery code like this: html += '<div class=index>' + item.index +
I have this code: var $msg = jQuery('<div></div>') .hide() .appendTo(document.body) ; if ($msg.is(:hidden)) {
I have this code in jquery : $(#order_btn).click(function(){ var totalprice = $(.price_amount).text(); $(#totalprice).val(totalprice); });
I have this code in jQuery.. $(document).ready(function(){ var fieldCounter = 0; ... I have
Using this jquery code: <a href=javascript:void(0) id=m1>Get Selected id's</a> jQuery(#m1).click( function() { var s;
hi here is my live page http://mehrdadkhoshbakht.com/test/index.html there is a jquery sliding animation on
Here is the entire page: <html> <head> <script type=text/javascript src=/jquery.js></script> <script type=text/javascript src=/json2.js></script> <script
I'm using the source code found on this site here: http://webtint.net/tutorials/5-star-rating-system-in-php-mysql-and-jquery/comment-page-1/#comment-2562 A fantastic resource,

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.