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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:24:11+00:00 2026-05-26T12:24:11+00:00

I have some mark-up like: <th>Header <a class=uiFilter>Filter</a></th> and some code like: $(‘.uiGridHeader th’).click(theadClick);

  • 0

I have some mark-up like:

<th>Header <a class="uiFilter">Filter</a></th>

and some code like:

$('.uiGridHeader th').click(theadClick); however I want to say if its the anchor that is clicked then DON’T do the function! The trigger also needs to happen on the TH so I can’t add an addition span to add the trigger on.

I’ve had a look at the jquery not api but not quite sure how to use it when passing a function call inside the click method.

I also have some actions on the anchor link so any prevention needs to allow the anchor to still execute code!

  • 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-26T12:24:12+00:00Added an answer on May 26, 2026 at 12:24 pm

    Either prevent the click event from bubbling when the a element was clicked:

    $('.uiGridHeader th a.uiFilter').click(function(event) {
        event.stopPropagation();
    });
    

    or test which element was clicked:

    $('.uiGridHeader th').click(function(event) {
        if(event.target === this) {
            theadClick.call(this, event)
        }
    });
    

    Update: If you bind any event handlers with .live or .delegate, then you have to use the second approach as these methods do not bind the event handler to the element itself, but the some ancestor of the element (or the document root).

    Update 2: If you have a more complicated nested structure, such as

    <th><span>Header</span> <a class="uiFilter"><span>Filter</span></a></th>
    

    you have to use some more jQuery trickery for the testing. For example, in the above case you could do:

    $(event.target).closest('a.uiFilter', this).length === 0
    

    This tests whether the clicked element is a.uiFilter itself or inside of it. The expression evaluates to true if not. The second parameter passed to closest restricts the search to the elements inside of this which is the table header element.

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

Sidebar

Related Questions

I have some classes layed out like this class A { public virtual void
I have some code like this in a winforms app I was writing to
I do have some strings that contains programming code, like XHTML (asp.net markup), C#,
I have some simple code for popping up a dialog-like thing over part of
Some Windows native applications have a question mark icon on the title bar. It's
I have some ASP.NET web services which all share a common helper class they
I have some code for starting a thread on the .NET CF 2.0: ThreadStart
I have some C# / asp.net code I inherited which has a textbox which
I have some code that batches addresses with 5 miles of each other. This
I have some code where I really want to call a virtual method from

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.