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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T12:22:52+00:00 2026-05-13T12:22:52+00:00

I have an <a> inside a <TD> , and I’m trying to have clicks

  • 0

I have an <a> inside a <TD>, and I’m trying to have clicks on the <TD>, but outside the <A>, act like they were clicks on the <a>. I’m almost there:

HTML:

<TD class="somethingPretty">
    <a href="someURL" class="anchor">Text</a>
</td>

JS:

$('.anchor').click(function(ev){return confirm("go ahead?");});
$('somethingPretty').click(function(ev){
    if($('.anchor').click()){
        document.location = $('.anchor').attr('href');
    }
}

The problem with this is that jQuery.click returns undefined, and I can’t see how to get at the event object that’s passed to the click handlers so I can interrogate it with isPropagationStopped and isDefaultPrevented. What’s the right way to solve this problem?

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

    Sometimes asking the question clearly is the best way to find an answer. Some strategic poking around the jQuery source led me to the following solution(using the markup above):

    $('.somethingPretty').click(function(ev){
        var syntheticClick = new $.Event("click");
        syntheticClick.stopPropagation();
        $('.anchor').trigger(syntheticClick);
        if(syntheticClick.isDefaultPrevented()) return;
        document.location = $('.anchor').attr('href');
    }
    

    This works for all event handlers except live-bound ones (those don’t execute; my users will have to learn to click the anchor itself for them!). The tricky part here is that trigger takes a jQuery.Event in addition to the documented string.

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

Sidebar

Related Questions

If I have some class Basis, and derived from it Derived, inside basis I
This is a function I have inside a class. $db is a mysqli object
It correct to define an outer class as static which have inside also a
i have inside the body main 'container' div and inside this 'container' div there
I've been trying to center this custom view I have inside this other custom
I have a page in html (parent page) that have inside an iframe. When
I have a problem when setting a variable inside a Java class Here is
I have a page like for example: http://www.stackoverflow.com/how-many-users-visited I have inside that page already
I have a link for headline, like the following, <a href=#>Cat<span class=more>See More</span></a> You
i have Linkbutton inside updatePanel and when i click on it it returns following

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.