Statement: The online information is complicated and makes me feel uncomfortable, a backend developer who is not familiar with the front end. Now I will integrate it. I hope it can help you some help (mainly help me (●ˇ∀ˇ●) to prevent loss)
html code component example
<div> <input type="radio" name="cgmd" value="study" checked="checked"><span class="cgsySpan">study</span> <input type="radio" name="cgmd" value="Visiting relatives"><span class="cgsySpan">Visiting relatives</span> <input type="radio" name="cgmd" value="Business"><span class="cgsySpan">Business</span> <input type="radio" name="cgmd" value="service"><span class="cgsySpan">service</span> <input type="radio" name="cgmd" value="travel"><span class="cgsySpan">travel</span> <input type="radio" name="cgmd" value="other"><span>other</span> </div>
radio settings selected
var obj = ("cgmd");//Get componentfor (var i=0;i<;i++){ //Judge value if(obj[i].value == 'study'){ //Setting obj[i].checked = true; } }
Radio settings are not optional
var obj = ("cgmd");//Get component// Set all unselectablefor (var i=0;i<;i++){ obj[i].disabled = true; }
When radio reads a certain value, select other radios and becomes unselectable (for reading data)
var CGMD = 'Visiting relatives' var obj = ("cgmd");//Get componentfor (var i=0;i<;i++){ //Judge value if(obj[i].value == CGMD){ //Setting obj[i].checked = true; }else{ //Settings are not optional obj[i].disabled= true; } }
Radio value changes event
$('input[type=radio][name=cgmd]').change(function() { (); });
Summarize
This is the article about JS control radio selecting, unselectable and changing events. For more related JS control radio selecting events, please search for my previous articles or continue browsing the related articles below. I hope everyone will support me in the future!