Unchecking radiobutton list using jquery

ε祈祈猫儿з 提交于 2019-12-11 12:24:13

问题


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


回答1:


$('#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.




回答2:


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.




回答3:


$('#radTopx').prop('checked',false); 


来源:https://stackoverflow.com/questions/1821166/unchecking-radiobutton-list-using-jquery

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!