Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jQuery - deselect same name radio buttons

 
Rob Hunter
Ranch Hand
Posts: 832
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have 3 radio buttons on a page, after selecting one, an action is performed, and the 3 radio buttons get hidden until a user clicks a button to redisplay them. When they re-appear I want to have the radio buttons to be all unchecked as they initially were (all = with the same name, i.e. leaving all other radio buttons alone on the page). What's the easiest way to accomplish this in jQuery? Thanks.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64980
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Remove the checked attribute from all of them. (Or try setting the checked attribute to Boolean false with the attr() method.)
 
Rob Hunter
Ranch Hand
Posts: 832
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply Bear. I was wondering more along the lines of how to select all radio buttons with a particular name then I was going to use removeAttr("selected") on the results. $('input <what else is needed>').removeAtr('selected'). Thanks again.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64980
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
selected is for <options> not radio buttons. Use checked.


To select:
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic