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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:32:57+00:00 2026-06-08T12:32:57+00:00

I have a listener for 3 DIV’s containing several form elements: <div id=div-a> <input

  • 0

I have a listener for 3 DIV’s containing several form elements:

<div id="div-a">
  <input type="text" id="txt-a"/>
  <!-- more elements here -->
  ...
</div>
<div id="div-b">
  <input type="text" id="txt-b"/>
  <input type="text" id="txt-c"/>
  <!-- more elements here -->
  ...
</div>
<div id="div-c">
  <input type="text" id="txt-d"/>
  <input type="text" id="txt-e"/>
  <input type="text" id="txt-f"/>
  <!-- more elements here -->
  ...
</div>

I bound the change event for the 3 DIV’s as follows:

$("#div-a, #div-b, #div-c").change(function(){
  // do something, except if the change happened to txt-b and txt-c
})

The above listens to change from all of their respective child elements. It works fine, but there is one thing more missing from the equation. The txt-b and txt-c change events is out of my business. So I must not include them in the action being performed by the change event listener. Also, each of the elements under the 3 DIV’s already have their own listeners for change so adding the listeners to each of the element’s change events is a last option.

I need to listen to changes from the child elements of the three DIV’s with some exceptions. I need to execute a function when the child elements of the three DIV’s change except for 5 input-types.

So far I did the following which did not work:

  1. I tried separating the three DIV’s and added the :not() selector

    $(“#div-b :not(#txt-b)”).change(function(){
    //…
    });

  2. Using .not()

I would like to know the best possible way to approach this problem. I’d be happy to add more information if you need so. Thank you.

  • 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-08T12:32:58+00:00Added an answer on June 8, 2026 at 12:32 pm

    You can try checking the target’s id for those and then ignore them:

    $("#div-a, #div-b, #div-c").change(function(e) {
        var target = e.target;
        if (target.id === "txt-b" || target.id === "txt-c") {
            return;
        }
        //Is not a txt-b or a txt-c
    })
    

    http://jsfiddle.net/HGXDT/4/

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

Sidebar

Related Questions

I have this event listener: input_1.addEventListener('input',function(){ updateFromInput(1); },false); It controls the location of a
Using YUI, I have a div, with an attached listener that says if I
I have a list of div elements created with javascript on the page that
I have some object (div, input/checkbox) in an HTML page. The values for their
I have pretty much the same question as stated here: Set listener for store
I have the following structure in a form: <div class='full'> <div class='half'> <label>Book</label> <select
I have an html form with seven text fields. I need a Javascript event
I have a snippet of jQuery in doc ready which toggles a div containing
I have following issue: I got an event listener on an input field. On
I have a bunch of div elements, all with a specific id. Inside these

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.