当我尝试动态创建按钮时,Internet Explorer会显示错误。虽然它在firefox中运行良好
var deleteButton = document.createElement('input');
ratingSliderContainer.appendChild(deleteButton);
deleteButton.setAttribute('type','button');
deleteButton.setAttribute('value','delete');
在第三行显示错误
答案 0 :(得分:7)
一旦输入添加到DOM,您就无法修改输入的type
。尝试重新排序你的陈述,如下:
var deleteButton = document.createElement('input');
deleteButton.setAttribute('type','button');
deleteButton.setAttribute('value','delete');
ratingSliderContainer.appendChild(deleteButton);