简体   繁体   中英

Preserve the default value of hidden radio button based on check box selection

I am using a list of check boxes (dynamically generated) with coressponding hidden radio buttons. By clicking on a check box its corresponding radio button (with value "YES" and "No") become visible having selected default value as "Yes". If I change the value of radio box as "NO" and desselect the check box, corresponding radio box becomes hidden again. On selecting the same check box again, its corresponding radio box appears but with value as "NO" (as selected before making it hidden). I want it to come with defult value "YES" . Please help.

Just update radio button value before making it visible. You can use

 $("#radioButtonId").prop("checked", true);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM