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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T02:32:05+00:00 2026-05-20T02:32:05+00:00

Not sure if this is a bug in jQuery 1.4.2 – I can’t figure

  • 0

Not sure if this is a bug in jQuery 1.4.2 – I can’t figure out why this won’t work.

I need to check a radio button. I’m using attr({'checked':'checked'}), I also tried attr('checked':true) – none will work. But if I do attr('title':'whatever') on the same radio button, with no other change anyhwere, that DOES work everytime.

Is there some obscure difference between the title attribute and the checked attribute that I’m missing? They are both your everyday HTML attributes. So why does one work and the other one doesn’t?

Here’s the code:

$('.formradiodiv').live('click', function() {
      //remove checked radio btns
      $('input', $(this).parents('#radiogroup')).each(function() {
            $(this).removeAttr('checked');
   });
      $('input', $(this)).attr('checked', true);
});

Edit: Alright, I believe I got it. Apparently it worked all along, and it was just my head temporarily being in tukka tukka land or something.

I was checking the source code to see if jQuery had added the “checked” attr to the radio button I was clicking on: in Firefox, highlight content, right click > View Selection Source. Doing this usually shows all changes to the DOM done by JavaScript, and I was expecting to see the attribute in the source code.

All this time, the HTML radio button was hidden via CSS. That’s the reason I need this in the first place – I’m replacing the default radio button with an image.

So in the source code, I didn’t see the checked attribute on the radio button, hence I assumed that it was jQuery not working correctly. But as soon as I removed the CSS rule, and showed the buttons for testing, I saw that they actually do get checked correctly. Nuff said.

Thank you very much to all who commented. I’ll vote y’all up.
Cheers

  • 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-20T02:32:06+00:00Added an answer on May 20, 2026 at 2:32 am

    Jab in the dark: I suspect that $('input', $(this)) matches other types of <input> elements besides check boxes, and that something goes wrong when setting the checked attribute of those elements.

    Try to restrict your selector to check boxes only (also note you don’t need to wrap this when using it as a selector context):

    $("input:checkbox", this).attr("checked", "checked");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm not sure if this is a bug or just some crazy new thing
Not sure if this is intended behavior or a bug or a wrong function
I'm not sure what this practice is actually called, so perhaps someone can edit
I have an IE bug that I'm not sure how to fix. Using jQuery
I'm sure this is a stupid bug that I'm missing but I can't seem
I'm not sure if this is a bug in Google Chrome or if this
Not sure this is a programming question, but we use LaTeX for all our
I am pretty sure this is possible just not sure what is the term
Not sure if this is possible or if I'm expressing correctly what I'm looking
I´m not sure if this is really a programming question, but it's related to

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.