开发者

JQuery change radio buttons checked state when each is selected

I have three radio buttons in a search group: Zip, City and County. How can I toggle the checked states of all radio buttons in the group when one of them is clicked?

开发者_StackOverflow
<input id="SC5_zipR" type="radio" value="" />
<input id="SC5_cityR" type="radio" value="" />
<input id="SC5_countyR" type="radio" value="" />

$("#SC5_zipR").prop('checked', true); //default checked value for zip code option

I am using Jquery 1.6.2. Thank you in advance, Attila


Give them all the same name. It's usually how radio buttons are done:

<input id="SC5_zipR" name="sc5" type="radio" value="zip" />
<input id="SC5_cityR" name="sc5" type="radio" value="city" />
<input id="SC5_countyR" name="sc5" type="radio" value="county" />

Demo here: http://jsfiddle.net/naveen/9jRPc/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜