I need to make a group of 2 radio buttons in my javascript for my web app. So far I have this code:
//radio buttons start
var AddRadio = function(options){
var _dom_element = document.createElement("radio");
for ( var i = 0; i < options.length; i++ ) {
var _option = document.createElement("radio");
_option.value = options[i];
_option.innerHTML = options[i];
_dom_element.appendChild(_option);
};
this.getDomElement = function() {
return _dom_element;
}
}
//radio buttons end
var _temp_radio = new AddRadio(['Max Temp', 'Min Temp']);
container_element.appendChild(_temp_radio.getDomElement());
The problem is that only the 'Max Temp' and 'Min Temp' strings show up, the actual radio buttons are not there. Thanks If you can help in any way.
radio buttons are
<input type="radio">.
You are creating a
<radio>
tag instead.
Use an <input type="radio"/>
tag.
eg
var option = document.createElement('input');
option.type = 'radio';
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.