There is a form:
<form> <div id='type'> <input type='radio' id='radio_1' name='type' value='1' /> <input type='radio' id='radio_2' name='type' value='2' /> <input type='radio' id='radio_3' name='type' value='3' /> </div> </form> How in jQuery or JavaScript to make so that when you click on a radio button, the <input> attribute is set to "checked="checked" ? As with the rest of the previously selected, this attribute should disappear. Ie, the selected button should always be present "checked="checked" .
For example, we selected the button with id='radio1' , it should have the checked attribute. After that we decided to choose another button with id='radio2' . After clicking on radio2 , the ckecked attribute appears to ckecked , and for id='radio1' this attribute disappears. And so on for all radio switches.
<input type='radio' id='radio_1' name='type' value='1' checked />||$('#radio_1').prop('checked')- lexxl