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

后端 未结 11 1545
深忆病人
深忆病人 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 13:02

    My suggestion is not to use document.Create(). Better solution is to construct actual HTML of future control and then assign it like innerHTML to some placeholder - it allows browser to render it itself which is much faster than any JS DOM manipulations.

    Cheers.

提交回复
热议问题