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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T17:29:01+00:00 2026-06-10T17:29:01+00:00

I have bound event as below: $(document).delegate(‘.budget’, ‘click’, function(e){ if ($(this).hasClass(‘collapsed’)) { $(this).removeClass(‘collapsed’); $(this).addClass(‘expanded’);

  • 0

I have bound event as below:

    $(document).delegate('.budget', 'click', function(e){
        if ($(this).hasClass('collapsed')) {
           $(this).removeClass('collapsed');
           $(this).addClass('expanded');
        }
        else if ($(this).hasClass('expanded')) {
           $(this).removeClass('expanded');
           $(this).addClass('collapsed');
        }
    });  

Basically this toggles between expand and collapse.

I have another event bound as below:

    $('[id^="tree"]').delegate('.collapsed', 'click', function(e){
        var elementId = $(this).attr('id');
        hideChildElement(elementId);
    });

The elements bound by the second event binding are parents of elements binded by first event binding.
What happens is that on clicking on the element from the first binding event method also triggers the event bound by second event binding.
I want to prevent any events from binding from second event binding to 1st event binding method.

If element A is bound to click event from first event binding and B is bound to second event binding (A is inside B or A is child of B), I dont want any event of B to propagate to A.
Note I tried e.stopImmediatePropagation(); but did not worked

  • 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-10T17:29:03+00:00Added an answer on June 10, 2026 at 5:29 pm

    I think you want to prevent the event handler bound to [id^="tree"] to be triggered if a .budged element was clicked. In that case you can test where the click event originated from:

    $('[id^="tree"]').delegate('.collapsed', 'click', function(e){
        if($(e.target).closest('.budget').length === 0) {
            // not from inside budget element
            var elementId = $(this).attr('id');
            hideChildElement(elementId);
        }
    });
    

    Alternatively, if you bind both event handlers to the same element, i.e. both to document or [id^="tree"] or any element in between, event.stopImmediatePropagation() will work just fine.

    If this is not what you want, please clarify your question, it is not easy to understand.

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

Sidebar

Related Questions

I have the following line bound to a click event: $(this).parents(.addonoptions).children().removeClass(highlight); It should strip
I have the following code bound to the click event of a button: function
I have some code bound to the blur() event in jQuery: $('input[type=text]').blur(function () {
I have created tabs by using jQuery API and have bound one event handler
I have a div that I have bound the jQuery hover event to activate
I have a gridview control that has on onclick event bound to every cell.
I have an event handler bound to the hover event using the .hover method,
What I have is 2 functions (edit and save), which are event handlers bound
In the page below,Topic__c is a single-select picklist. My intention is to have this
I have a RadComboBox that i have bound like shown below <telerik1:RadComboBox Grid.Row=2 Grid.Column=1

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.