我写了一段代码用JS创建了一组checkboxvar input = document.createElement('INPUT');
input.type = 'checkbox';
input.name = 'xxx';//然后调用了一个td的appendChild方法//在页面上也可以看到控件显示正常//但是跟断点发现控件的outerhtml属性是 <input type='checkbox'>,没有name属性等到我用的时候document.getElementsByName('xxx');得到的数组长度是0不知道怎么回事
input.type = 'checkbox';
input.name = 'xxx';//然后调用了一个td的appendChild方法//在页面上也可以看到控件显示正常//但是跟断点发现控件的outerhtml属性是 <input type='checkbox'>,没有name属性等到我用的时候document.getElementsByName('xxx');得到的数组长度是0不知道怎么回事
input.type = 'checkbox';
input.name = 'xxx';这种方法在IE8、FF下没有问题。但在IE6下面失败,可以改用
var input = document.createElement("<INPUT name='xxx'>");