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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:15:34+00:00 2026-06-18T12:15:34+00:00

Unless I am mistaken. jQuery and CSS handle the :checked selector very differently. In

  • 0

Unless I am mistaken. jQuery and CSS handle the :checked selector very differently. In CSS when I use :checked, styles are applied appropriately as I click around, but in jQuery it only seems to recognize what was originally in the DOM on page-load. Am I missing something?

Here is my Fiddle

In jQuery:

$('input:checked').click(function () { 
   $('input:checked').css('background','#FF0000');
   $('input:checked+label').css('background','#ff0000');
});

In CSS:

input:checked+label {font-weight:bold;color:#5EAF1E}

UPDATE:
I should clarify that what I am looking to do is trigger behavior if a user clicks an already selected radio button.

  • 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-18T12:15:35+00:00Added an answer on June 18, 2026 at 12:15 pm

    AFTER UPDATE

    Keep track of the status of the radio buttons. For example, use .data() to keep an in-memory state of the radio buttons.

    $(function () {
        var $radio = $(":radio");
        $radio.filter(":checked").data("checked", true);
        $radio.on("click", function () {
            if ($(this).data("checked")) {
                alert("Already selected");
            }
            $radio.data("checked", false).filter(":checked").data("checked", true);
        });
    });
    

    See it live here.


    BEFORE UPDATE

    I think you want to use .change() here.

    $('input:radio').change(function () {
        $('input, input+label').css('background', '');
        $('input:checked, input:checked+label').css('background', '#f00');
    }).change();
    

    See it live here.

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

Sidebar

Related Questions

Newbie question: unless I'm mistaken, most attributes appear to be benign until you use
Unless I'm mistaken, creating a function in Python works like this: def my_func(param1, param2):
Unless I am doing something wrong, the way I am supposed to use ConfigurationSection,
Unless I am thoroughly mistaken, the getter/setter pattern is a common pattern used for
I have always understood (unless im mistaken) that Apache's modrewrite engine requires Options +FollowSymLinks
I'm having trouble splitting a QString properly. Unless I'm mistaken, for multiple delimiters I
Unless I am mistaken, it should be possible to create a std:array in these
Unless I'm mistaken (which I hope I am) there is a bug with the
Unless I'm mistaken, it is legal to have an array in Java indexed by
I have come across IE8's 31 CSS file limit. I am thinking that, unless

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.