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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:17:15+00:00 2026-05-30T07:17:15+00:00

I’m trying to apply CSS to the element next to a radio button, but

  • 0

I’m trying to apply CSS to the element next to a radio button, but nothing happens:

 $('.ordering-options input[type="radio"]').live("change", function(){
    $('input[type="radio"]:checked').next().css('color', 'red');
  });

(I also want the default checked radio button to have the CSS applied before any action)

Any suggestions in order to accomplish this?

EDIT: The CSS is applied and disappears in a second.

HTML:

<fieldset class="ordering-options">
    <h2 class="ordering-method">Ordering method:</h2>

    <ul>
      <li><input type="radio" name="take-out" value="false" checked="checked" class=
      "takeout-select" /><span>Take Out</span></li>
    </ul>

    <ul>
      <li><input type="radio" name="delivery" value="true" class=
      "delivery-select" /><span>Delivery</span></li>
    </ul>
  </fieldset>

(‘Take out’ is red by default. If the user clicks ‘Delivery’, the span after it will turn red and vice versa).

  • 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-30T07:17:16+00:00Added an answer on May 30, 2026 at 7:17 am

    I’m not sold on that HTML structure, but if you’d like to stick with it you could use the following: jsFiddle

    function colorRadio(){
        $('.ordering-options input[type="radio"]').closest('li').find('span').css('color', 'black');
        $('.ordering-options input[type="radio"]:checked').closest('li').find('span').css('color', 'red');
    }
    colorRadio()
    $('.ordering-options input[type="radio"]').on("change", colorRadio);
    

    It’s a function that first resets all the labels to ‘black’, then changes the checked ones to ‘red’. You run it once on page-load, then once for every change of a radio button.

    PS: if you want “radio” buttons they have to have the same “name” or they aren’t linked

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

Sidebar

Related Questions

I need to clean up various Word 'smart' characters in user input, including but
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

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.