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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T10:07:28+00:00 2026-06-07T10:07:28+00:00

There is a <label> with a <a href=#> element inside. I’d like to prevent

  • 0

There is a <label> with a <a href="#"> element inside. I’d like to prevent the default behaviour of the <a> element (i.e. navigating) but it should execute the default behaviour of the <label> element (i.e. checking the checkbox inside it).

Test case: http://jsfiddle.net/3M6WE/. Clicking foo toggles the checkbox. Clicking bar does not navigate but neither toggles the checkbox.

How can I have the <a> element not navigate but have it toggle the checkbox? I’d like to avoid hacks like toggling the checkbox manually. I’m looking for a “partly” preventDefault, if available.

  • 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-07T10:07:31+00:00Added an answer on June 7, 2026 at 10:07 am

    you could trigger the click of the parent element (the label):

    http://jsfiddle.net/3M6WE/11/

    $("a").on("click", function(e) {
        e.stopPropagation();
        $(this).parent().click();
        // do stuff...
        e.preventDefault();
    });
    

    then do some magic and finally call preventDefault();

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

Sidebar

Related Questions

Is there a way to display a node label centered inside the node such
There is a label containing a <p> tag in my html code. but firefox
private List nodes = new List(); there is a label field inside ISilverNodeModel class
For a System.Windows.Forms.Label is there a way to auto-fit the label font size depending
Is there a way to take a text label and an URL and use
Is there any way to have a label wordwrap text as needed? I have
Is There any way to show value and label both in sencha pie chart?
Is there a way to do something similar to a SourceSafe label in svn?
There is one problem occurring when I am trying to dynamically generate the label
According to MSDN ( http://msdn.microsoft.com/en-us/library/system.windows.forms.label.autosize.aspx ), there's a note about Label 's AutoSize property:

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.