HERE is your solution. You only need to remove the braces to compare the class
$("input:radio[class^=radio2]").each(function(i) {
Question
Is it possible to uncheck a radio button based on class?
$('#button').click(function () {
$("input:radio[class^='.radio2']").each(function(i) {
this.checked = false;
});
});
JsFiddle = http://jsfiddle.net/nPgyd/1/
This doesn't appear to work.
Solution
HERE is your solution. You only need to remove the braces to compare the class
$("input:radio[class^=radio2]").each(function(i) {
OTHER TIPS
Try
$('#button').click(function () {
$(".radio2").each(function(i)
{
this.checked = false;
});
});
This might be helpful for you.
$('#button').click(function () {
$("input:radio.radio2").each(function(i) {
$(this).attr('checked',false);
});
});
Check the link...
Yes you can, the syntax required is not nearly as complex as that.
$('#button').click(function ()
{
$(".radio2").each(function(i)
{
this.checked = false;
});
});
Or if you want only inputs with the class radio2 to be affected:
$('#button').click(function ()
{
$("input.radio2").each(function(i)
{
this.checked = false;
});
});
Try something like this?
$('#button').click(function () {
$("input[type='radio'].radio2").each(function () {
$(this).prop('checked', false);
});
});