JonH
JonH

Reputation: 33163

How do I set radiobuttonlist selected value in jquery

Server side asp.net radiobuttonlist. The value for the radiobuttonlist are ints with values 0, 1. The text values are file, url.

So 0=File, 1=URL.

How in jquery can I set this radiobuttonlist value to 0? I tried:

$('#<%=rbAttachmentType.ClientID %>').find("input[value='0']").attr("checked", "checked");

But this did not seem to work.

Upvotes: 3

Views: 10307

Answers (1)

Arun P Johny
Arun P Johny

Reputation: 388406

You need to use .prop() instead of .attr() to set the checked state

$('#<%=rbAttachmentType.ClientID %>').find("input[value='0']").prop("checked", true);

Upvotes: 9

Related Questions