10 examples of 'jquery set radio button checked based on value' in JavaScript

Every line of 'jquery set radio button checked based on value' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
74function set_radio_checked(id) {
75 $('#' + id).prop('checked', true);
76}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

78function set_checkbox_value(id, value) {
79 $('#' + id).prop('checked', value);
80}
74function setCheckedValue(radioObj, newValue) {
75 if (!radioObj)
76 return;
77 var radioLength = radioObj.length;
78 if (radioLength == undefined) {
79 radioObj.checked = (radioObj.value == newValue.toString());
80 return;
81 }
82 for (var i = 0; i < radioLength; i++) {
83 radioObj[i].checked = false;
84 if (radioObj[i].value == newValue.toString()) {
85 radioObj[i].checked = true;
86 }
87 }
88 }
19public set checked(value: boolean){
20 if(!value){
21 this.el.removeAttribute("checked");
22 }else{
23 this.el.setAttribute("checked", "checked");
24 }
25}
38set checkedButton(value: number) {
39 this._setValue(checkedButtonProperty, value);
40}
42function checkRadioButton() {
43 document.getElementById('control2').setChecked(true);
44}
23public isChecked(): boolean {
24 return !!this.select('CHECKED_RADIO_ICON');
25}
69function checkRadioButton( name, value ){
70 var radiobuttons = document.querySelectorAll('input[name="'+name+'"]')
71 for( let i = 0, lg = radiobuttons.length; i<lg; i++ ){
72 if( radiobuttons[i].value == value ){
73 radiobuttons[i].checked = true
74 }
75 }
76}
757function setRadio(name, val, callback){
758 $("input[name=" + name + "]").on('change', function() {
759 var state = $("input[name="+name+"]:checked").val();
760 callback(state);
761 });
762 $(".radio>input[value="+val+"]").prop("checked", true);
763}
104_setChecked (value, el, item) {
105 if (el.value === value) {
106 el.checked = true
107 this._init = el.checked
108 item.init = el.checked
109 item.value = value
110 }
111}

Related snippets