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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:07:32+00:00 2026-05-17T00:07:32+00:00

I have added stopPropagation, however, I still get two popups in a row. This

  • 0

I have added stopPropagation, however, I still get two popups in a row. This is better than before, where there were 20 popups for one element that is clicked….is there a better approach or am I missing something ?

$(top.document).ready(function () {

    $("*").click(processAction);

});

function processAction(e) {
    var clicked = e.target;
    e.stopPropagation();
    alert(clicked.tagName);
    e.stopPropagation();
    switch (clicked) {
    case "A":
        //execute code block 1
        break;
    case "INPUT":
        //execute code block 2
        break;
    default:
        //code to be executed if n is different from case 1 and 2
    }
};
  • 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-17T00:07:33+00:00Added an answer on May 17, 2026 at 12:07 am

    I’d say definitely do not place a click handler on every element. As @Rin stated, you can assign them by tag, or some other selector.

    If you really want to process all clicks on the page that way, I’d suggest that you place one handler on the document, and let the click events bubble up to that.

    This is much more efficient and there’s no need to do e.stopPropagation().

    Example: http://jsfiddle.net/y6hry/

    $(top.document).ready(function () {
           // All clicks on the page will bubble up to the document
           //   and fire the handler.
        $(document).click(processAction);
    });
    
    function processAction(e) {
        var clicked = e.target;
        alert(clicked.tagName);
        switch (clicked.tagName) {
        case "A":
            //execute code block 1
            break;
        case "INPUT":
            //execute code block 2
            break;
        default:
            //code to be executed if n is different from case 1 and 2
        }
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have added this to a class comment: @link http://www.google.com Google @endlink However, when
I have added an extra field Specification in Catalog->Product->Data tab. This text is stored
I have this code: var originalBorder = container.css("border"); container.hover(function(event) { event.stopPropagation(); $(this).css("border", "1px solid
I have added a tableview with 10 records. The last row is the load
I have added a field in wordpress posts table named parent_location. How to get
I have added sprites to my NSMutable Array now I'd like to get to
We have added a yes/no product attribute labelled: Allow this product to have coupons
I have added this function in my user class. Is this function Place in
I have added two swipe gesture recognizers (swipe left and swipe right) to my
I have added a button inside a loginview, but then this code is not

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.