Recently done a lot of front-end page work, encountered a feeling very headache in the matter here to remember:
Often use JS to echo the radio box, but clearly from the page effect, the Radio box has been selected, but it can not trigger the Change event, the value of the time to take a certain method can not take the selection of the selected box value (single box to take the value of a number of methods, I mean some can be taken, some methods do not get).
Think for a long time, a set of seemingly complex but very practical JS echo method. experimented with a variety of front-end frameworks and browsers. Let's say we need to echo the single box with name Gender,value 1:
$ ("[name= ' Gender '][value=1]"). attr ("Checked", "checked"). Prop ("checked", true). Trigger ("change");
Attr and prop can guarantee that any method that gets the value of the selected radio box can be obtained, and the trigger method manually triggers the change event for the radio box. If the event of your radio box is another event, simply change the change to the appropriate event.
JS implements the radio button echo when the page effect appears, but the value of the selected radio box is empty