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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:32:37+00:00 2026-05-23T08:32:37+00:00

I am using a jQuery that is styling my checkbox, meaning that, on click,

  • 0

I am using a jQuery that is styling my checkbox, meaning that, on click, it changes the style of the checkbox (onchange actually).
My problem is: the values I select are taken from a database, on one part, and modified by users on the other part.
So, if a condition is fulfilled, I want that radio button to be checked. I wonder how can I do this in my jQuery function: (code below:)

  <script type="text/javascript">
    $(document).ready(function(){
$(".CheckBoxClass").change(function(){
    if($(this).is(":checked")){
        $(this).next("label").addClass("LabelSelected");
    }else{
        $(this).next("label").removeClass("LabelSelected");
    }                            

});

    });
   </script>

And the HTML:

  <form id="address" method="POST" action="<?= Route::url('Save user preferences' , array('user_id' => $user));?>">
 <? foreach ($prefered_products as $pp): ?>
 <input id="CheckBox[<?= $pp; ?>]" type="checkbox" class="CheckBoxClass" style="display: none;" name="user_preferences_preference[<?= $pp->id ?>]" value="<?= $pp ?>" checked="checked" />
 <label id="Label[<?= $pp; ?>]" for="CheckBox[<?= $pp; ?>]" class="CheckBoxLabelClass"><?= $pp->product; ?></label>

Salveaza preferintele tale

The function is only onchange. I also want that, if exists the attr cheched = “checked”, the checkbox to be checked (the checked style to be displayed).

Is this possible in the given conditions?

  • 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-23T08:32:38+00:00Added an answer on May 23, 2026 at 8:32 am
    $(".CheckBoxClass:checked").each(function(){
      $(this).next('label').addClass("LabelSelected");
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I select elements (using jQuery) that do not contain any elements? For
Using the checkbox styling system here (with a few slight modifications): http://blogs.digitss.com/javascript/jquery-javascript/jquery-fancy-custom-radio-and-checkbox/ I have
I have a jQuery accordion that I am styling using the ui themes. My
Is there a way using JQuery that i can detect when a div starts
I am writing a site using jquery that repeatedly calls $(window).width() and $(window).height() to
A while back I created a lightbox plugin using jQuery that would load a
So I'm using some jQuery that I found online. There's a lot of variations
I am using this jquery function that works fine in win/mac FF 3.5 and
I'm using a jQuery plugin that has its functions defined as such: $('#mydiv').pluginAction({ someproperty:
Using jQuery I'm creating a basic 'tooltip' animation so that the tooltip will appear

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.