How do you dynamically create a radio button in Javascript that works in all browsers?

后端 未结 11 1540
深忆病人
深忆病人 2020-12-01 12:12

Dynamically creating a radio button using eg

var radioInput = document.createElement(\'input\');
radioInput.setAttribute(\'type\', \'radio\');
radioInput.se         


        
11条回答
  •  臣服心动
    2020-12-01 12:35

    Personally I wouldn't create nodes myself. As you've noticed there are just too many browser specific problems. Normally I use Builder.node from script.aculo.us. Using this your code would become something like this:

    Builder.node('input', {type: 'radio', name: name})
    

提交回复
热议问题