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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T02:40:08+00:00 2026-06-05T02:40:08+00:00

I don’t know why when a checkbox is clicked, it double the label text

  • 0

I don’t know why when a checkbox is clicked, it double the label text associated. Could anyone help me?

// add multiple select / deselect functionality
                $("#selectall").click(function () {
                    $('.child').attr('checked', this.checked);
                    $('.ck,.chkbox,.checkAll ,input:radio').DcustomInput();
                }); 

jQuery.fn.DcustomInput = function(){
                    $(this).each(function(i){   
                        if($(this).is('[type=checkbox],[type=radio]')){
                            var input = $(this);
                            var id=input.attr('id');


                        // get the associated label using the input's id
                        var forlabel = $('label[for='+input.attr('id')+']');
                        var chklabel = forlabel.text();
                        forlabel.hide();
                        var label = $("<label  for='"+id+"' class='checker'>"+chklabel+"</label>");

                        //get type, for classname suffix 
                        var inputType = (input.is('[type=checkbox]')) ? 'checkbox' : 'radio';   
                        //  alert(label);
                        // wrap the input + label in a div 
                        $('<div class="custom-'+ inputType +'"></div>').insertBefore(input).append(input, label);

                        // find all inputs in this set using the shared name attribute

                        if(input.is(':disabled')){
                            if(inputType == 'checkbox' && input.is(':checked')){ 
                                label.addClass(' checkedDisabled '); 
                            } else{
                                label.addClass(' disabled ');   
                            }
                        }

                        // necessary for browsers that don't support the :hover pseudo class on labels
                        label.hover(
                        function(){ 
                            if(!input.is(':disabled') ){
                                $(this).addClass('hover');
                            }
                            if(inputType == 'checkbox' && input.is(':checked') && !input.is(':disabled')){ 
                                $(this).addClass('checkedHover'); 
                            } 
                        },
                        function(){ $(this).removeClass('hover checkedHover focus'); }
                    );

                        //bind custom event, trigger it, bind click,focus,blur events                   
                        input.bind('updateState', function(){   
                            if (input.is(':checked') && !input.is(':disabled')) {
                                if (input.is(':radio')) {   
                                    var allInputs = $('input[name='+input.attr('name')+']');
                                    allInputs.each(function(){
                                        $('label[for='+$(this).attr('id')+']').removeClass('checked');
                                    });     
                                };
                                label.addClass('checked ');
                            }
                            else { label.removeClass('checked checkedHover checkedFocus '); }

                        })
                        .trigger('updateState')
                        .click(function(){ 
                            $(this).trigger('updateState'); 
                        })
                        .focus(function(){ 
                            label.addClass('focus'); 
                            if(inputType == 'checkbox' && input.is(':checked')){ 
                                $(this).addClass('checkedFocus'); 
                            } 
                        })
                        .blur(function(){ label.removeClass('focus checkedFocus'); });
                    }
                });
            };
        </script>
  • 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-05T02:40:09+00:00Added an answer on June 5, 2026 at 2:40 am

    ok, I’ve found the solution, just comment these 2 lines:

    forlabel.hide();
    $('<div class="custom-'+ inputType +'"></div>').insertBefore(input).append(input, label);
    

    so that the old label is not hidden and we don’t try to duplicate the input and the old label.

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

Sidebar

Related Questions

Don't know if anyone can help me with this or if it's even possible.
Don't know why but font is not displaying.Please help. CSS(in css folder): style.css: @font-face
Don't know what to do with this error. How to add data in SQL
I don't know why this double json response are not successful: [{first_content:content,...}][{second_content:content,...}] So i
Don't exactly know what to search for: If i edit text in vim it
I don't know when to add to a dataset a tableadapter or a query
Don't know why this conversion fails. SELECT CAST('32.999' AS INT) throws the error saying
Don't really know how to formulate the title, but it should be pretty obvious
Don't know how to google for such, but is there a way to query
I don't know whether this is really possible, but I'm trying my best. If

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.