user1181690
user1181690

Reputation: 1523

How to make all radio buttons unselected

This makes a textarea go blank in my application:

$('#questionTextArea').val('');

What I want to know is how can I make radio buttons go back to all being unselected? the class of each radio button is .replyBtn

Upvotes: 1

Views: 2745

Answers (3)

ShadowStorm
ShadowStorm

Reputation: 851

For jQuery version 1.6 and above, you should use:

$(".replyBtn").prop('checked', false);

Before jQuery version 1.6, you could use:

$(".replyBtn").attr("checked", false);

But it is best to use the .prop method, as in version 1.6, they are trying to keep .attr only for attributes and .prop for properties.

Upvotes: 2

Andrew Whitaker
Andrew Whitaker

Reputation: 126052

Check out .prop:

$(".replyBtn").prop("checked", false);

Example: http://jsfiddle.net/WdUpn/

Upvotes: 4

JaredPar
JaredPar

Reputation: 754783

Try the following

$('.replyBtn').each(function () { $(this).attr('checked', false); });

Fiddle: http://jsfiddle.net/cM8Lq/1/

Upvotes: 2

Related Questions