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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T18:52:11+00:00 2026-06-04T18:52:11+00:00

I have a label and some functions running while clicking on it. But when

  • 0

I have a label and some functions running while clicking on it.

But when a click event is made, a double click event is done, then my functions run 2 times…

You can see a light example here

HTML:

<label>
<input type="checkbox" id="checkbox"> Click here
</label>
<input type="text" id="test" value="0"/> clicks​​​

JavaScript:

$(document).ready(function(){
    $('label').click(function(event) {
         $('#test').val(parseInt($('#test').val())+1);
         event.preventdefault();
    });
});​
  • When we click on the checkbox, the clicks counter is +1 >> Ok
  • When we click on the label, the clicks counter is +2 >> Nok

How to solve this problem ?

Edit

preventdefault() to preventDefault() fixed the double click, but now checkbox is not checked anymore…

  • 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-04T18:52:13+00:00Added an answer on June 4, 2026 at 6:52 pm

    Well this is interesting. You’re seeing two click events, one of them from the checkbox input, and the other (of course) from the label. And it makes sense: Clicking a label is like clicking the checkbox the label labels, by design. Here’s an updated fiddle showing what’s happening.

    So just hook click on the checkbox and don’t hook it on the label:

    $(document).ready(function(){
        $('#checkbox').click(function(event) {
            $('#test').val(parseInt($('#test').val())+1);
        });
    });​
    

    Updated fiddle


    And as Rocket said in the question’s comments: preventDefault has a capital D in it, so your code was throwing an exception. But you didn’t want preventDefault anyway, because you want the checkbox to be checked.

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

Sidebar

Related Questions

I have asp label in my asp page and its text is some my
Say I have a label control in Winforms and I want to do some
I want to have a left justified label with some bold text in it,
I have panel that is using group layout to organize some label. I want
I have a label like <label for=Some Feild >Some Text </label> Now I want
I'm trying to get wxCheckBox to have sensitive label like it is in some
I have some troubles with positioning my label/password field. With this code they both
for some reason the label in my uitableviewcell changes position when I have an
I have some HTML like this: <input type=radio class=MyRadio name=TheName> <label for=TheLabel>the text</label> How
I have been doing some research on this but found no clear answer. The

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.