Unchecking radiobutton list using jquery

2019-08-03 00:08发布

Ok, last question for today I promise!

I have the following line of code that features a radio button list (radTopx)

ddlBuyer.Attributes.Add("onclick", "$('#tbxProdAC').val(''); $('#txtbxHowMany').val(''); $('#GridView1').remove(); $('#radTopx').attr('checked',false); ");

What I am trying to achieve is that when ddlBuyer is clicked, radTopx has all it's radio buttons unchecked.

I am obviously doing this incorrectly at present, please can someone pointout where I have gone wrong? Does this work differently in a radio button list to a standard radio button?

Where #radTopx represents the following radio button list :

RadioButtonList ID="radTopx"

    ListItem>UUF1<ListItem>
    ListItem>UUF2<ListItem>
    ListItem>UUF3<ListItem>

RadioButtonList

3条回答
Rolldiameter
2楼-- · 2019-08-03 00:12
$('#radTopx').prop('checked',false); 
查看更多
Anthone
3楼-- · 2019-08-03 00:31
$('#ddlBuyer').click(function() {
    $('div#radios input').attr('checked',false);
});

where div#radios encloses all your radio inputs. I'm assuming ddlBuyer is the id of something that gets clicked.

We can't give an answer in regard to #radTopx since we don't know what it is.

查看更多
The star\"
4楼-- · 2019-08-03 00:34

Thank you very much Carillonator, greatly appreciated.

The following code did the trick, I just need to add in the 'input'

ddlBuyer.Attributes.Add("onclick", "$('#tbxProdAC').val(''); $('#txtbxHowMany').val(''); $('#GridView1').remove(); $('#radTopx input').attr('checked',false); ");

Where #radTopx is the radio button list.

查看更多
登录 后发表回答