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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T01:59:20+00:00 2026-06-17T01:59:20+00:00

Possible Duplicate: jQuery – on() function when a div is clicked, but not when

  • 0

Possible Duplicate:
jQuery – on() function when a div is clicked, but not when a child of that div is clicked

$(oTrPlanning).prev().children('td').each(function () {
    this.onclick = setCountClick;
});

On click of TD setCountClick() is called but TD also contains a Textbox:

<td> 
    <input class="Input-InlineFilter" id="TextFirst"  type="text" value="">
</td>

So, when I start typing something on Textbox, setCountClick() is again called.
I want to call setCountClick() when TD is clicked, but not Textbox.

  • 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-17T01:59:21+00:00Added an answer on June 17, 2026 at 1:59 am

    The click event bubbles up the DOM from the textbox to the td, all the way to body. If you don’t want textbox clicks to trigger the td click handler, you need to stop the bubbling:

    $('#TextFirst').click(function (e) {
        e.stopPropogation();
    });
    

    Documentation for stopPropagation

    To expand, you should be taking advantage of this bubbling to only bind one event handler for all tds:

    // bind one handler to all tds
    $(oTrPlanning).prev().on('click', 'td', function (e) {
        // ensure the clicked element is a TD
        if (this.nodeName === 'TD') {
            setCountClick(e);
        }
    });
    

    Documentation for nodeName

    Be aware that if you are relying on the this operator anywhere inside of setCountClick, it may no longer work as expected. To fix that you would need to look into using $.proxy or bind when you call setCountClick:

    setCountClick.bind(this)(e);
    

    bind returns a new function that uses the argument you pass as the this parameter inside the new function. Then you execute that function and pass it your regular parameters.

    Documentation for bind

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

Sidebar

Related Questions

Possible Duplicate: jQuery each this I have a loop that iterates over every element
Possible Duplicate: jQuery bind click ANYTHING but ELEMENT I have this HTML <div id=outer>
Possible Duplicate: jquery on vs click methods I understand that $(parent).on('click', 'element', function(){ ...
Possible duplicate: jquery change div text The above question is a possible duplicate, but
Possible Duplicate: Jquery event chaining Traditionally we may write: $(selector).click(function () { }); but
Possible Duplicate: jQuery: how do I animate a div rotation? I have a div
Possible Duplicate: jquery data selector I have several elements with class 'connection_name'. Each one
Possible Duplicate: Merging jQuery objects See Demo a = $('div:eq(0)'); b = $('div:eq(1)'); c
Possible Duplicate: Bind multiple events to jQuery 'live' method I have the following function:
Possible Duplicate: jQuery - How to Use slideDown (or show) function on a table

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.