简体   繁体   English

无法让单选按钮出现在页面上

[英]can't get radio buttons to appear on page

I need to make a group of 2 radio buttons in my javascript for my web app.我需要在我的 javascript 中为我的网络应用程序制作一组 2 个单选按钮。 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.问题是只有“Max Temp”和“Min Temp”字符串出现,实际的单选按钮不存在。 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.使用<input type="radio"/>标签。

eg例如

var option = document.createElement('input');
option.type = 'radio';

http://www.w3schools.com/html/html_forms.asp http://www.w3schools.com/html/html_forms.asp

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM