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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:34:07+00:00 2026-05-26T07:34:07+00:00

I’m trying to customize radio buttons with jquery. I know there are tons of

  • 0

I’m trying to customize radio buttons with jquery.
I know there are tons of solutions working out there, but I need to set a different image for each radio button. This is needed because there is no label description, so each radio button must be styled to understand its meaning (example: two radio buttons, one with an image containing “$” and one “€” to check the preferred currency).

I’m creating a simple function called “Stylize” (actually I’ve tried it only on firefox, but I’ll make it work up to IE6/7 and previous versions of major browsers).

By the way the function doesn’t seem to work as expected, because it sets the checked attribute on all radio buttons, giving a weird result.

Here is the fiddle containing a simple example. I’ve analyzed the attributes with firebug. Actually it doesn’t accept a different class name for each radio button, but this is the next step. As you can see the solution I’m working on is to wrap the radio button with an anchor tag and then bind a onclick event handler to select its radio button.

What can I do to make it work properly?
Thank you, Alex.

  • 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-26T07:34:08+00:00Added an answer on May 26, 2026 at 7:34 am

    Here’s a working example: http://jsfiddle.net/bFYW6/2/

    Your problem was quite simple: You called var wrapper = $(radio).parent(); before actually wrapping the radio element. Therefore, .parent() referred to the <form> element, not the <a> that you went on to wrap the radio element in.

    All I did was switch the order of those two lines and voila!

    Another change you could make would be to the final line that actually binds the click event on the wrapper. Rather than:

    $(wrapper).click(function() {
        $(radio).attr("checked", true);
    });
    

    You could do:

    $(wrapper).click(function() {
        $(this).children().attr("checked", true);
    });
    

    By using $(this) in the above example, it will always find the radio element that is it’s child. That allows you to then call the Stylize() function just once: Stylize("#radio1, #radio2"); or Stylize("input[type=radio]");.

    Example: http://jsfiddle.net/bFYW6/6/

    As a final point, you shouldn’t use a capital ‘S’ for your Stylize() function. Beginning a function with a capital letter in JavaScript generally suggests that it is a constructor function for a class, which yours is not.

    • 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'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
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 reading a book about Javascript and jQuery and using one of the
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

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.