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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T11:03:50+00:00 2026-05-30T11:03:50+00:00

I have this iPhone like checkbox script, which makes beautiful checkboxes. The code is

  • 0

I have this iPhone like checkbox script, which makes “beautiful” checkboxes. The code is like this:

$(document).ready( function(){ 
    $(".cb-enable").click(function(){
        var parent = $(this).parents('.switch');
        $('.cb-disable',parent).removeClass('selected');
        $(this).addClass('selected');
        $('.checkbox',parent).attr('checked', true);
    });
    $(".cb-disable").click(function(){
        var parent = $(this).parents('.switch');
        $('.cb-enable',parent).removeClass('selected');
        $(this).addClass('selected');
        $('.checkbox',parent).attr('checked', false);
    });
});

And the HTML:

Yes
No

New personal message

                <p class="switch"> 
                <label class="cb-enable" ><span>Yes</span></label>
                <label class="cb-disable selected"><span>No</span></label>
                <div style="display:none;"><input type="checkbox" id="checkbox2" class="checkbox" name="notify_on_support" value="1" style="" /></div> 
                <label for="ticketreply" class="label" style="font-size:12px">Reply to support ticket</label><br />                    
                </p>

                <p class="switch"> 
                <label class="cb-enable"><span>Yes</span></label>
                <label class="cb-disable selected"><span>No</span></label>
                <div style="display:none;"><input type="checkbox" id="checkbox3" class="checkbox" name="notify_on_event" value="1" style="" /></div> 
                <label for="nevent" class="label" style="font-size:12px">New Events</label><br />
                </p>

                <p class="switch"> 
                <label class="cb-enable"><span>Yes</span></label>
                <label class="cb-disable selected"><span>No</span></label>
                <div style="display:none;"><input type="checkbox" id="checkbox4" class="checkbox" name="notify_on_pupdate" value="1" style="" /></div>
                <label for="pupdate" class="label" style="font-size:12px">Profile Update</label><br />                 
                </p>
            </div>            

The problem here is, that only the FIRST part of the html (the first checkbox) works. The rest, the checkbox is not checked.

I guess it have something to do with the jQuery code, I am just not sure what.

Thanks in advance.

  • 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-30T11:03:52+00:00Added an answer on May 30, 2026 at 11:03 am

    The problem you have is that including a <div> element inside a <p> element isn’t valid, so the browser is rendering them as siblings rather than rendering the <div> as a descendent of the <p> element. Then, obviously, your jQuery code doesn’t find the <input> element, and the value never gets changed.

    Simply removing the <div> element and applying the style="display:none;" attribute to the <input> element directly fixes the problem.

    Working DEMO

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

Sidebar

Related Questions

This is on the iPhone. So what if I have a function like -
I have this code trying to run a video on the iPhone 4 Simulator.
I'm trying to implement iPhone like PIN-code authorization with 4 EditText blocks like this:
So I have this iPhone app with a nested setup like this: [RootViewController]->[UITabBarController]->[UINavigationController]->[subViewControllers]. Everything
I have this chronic issue with iPhone UI development where views sometimes seem to
I am pretty new to this iPhone dev thing but so far I have
Im new to iPhone development and I have really taken this to me. I
My question is this: I have an application designed for iPhone and I decided
Although I don't have an iPhone to test this out, my colleague told me
I have a few questions about this after reading the iPhone documentation on it:

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.