我尝试动态创建按钮时,Internet Explorer显示错误。鉴于它在Firefox中工作正常

var deleteButton = document.createElement('input');
 ratingSliderContainer.appendChild(deleteButton);
 deleteButton.setAttribute('type','button');
 deleteButton.setAttribute('value','delete');

第三行显示错误

最佳答案

将输入添加到DOM后,您将无法修改其type。尝试像这样重新排列语句:

var deleteButton = document.createElement('input');
deleteButton.setAttribute('type','button');
deleteButton.setAttribute('value','delete');
ratingSliderContainer.appendChild(deleteButton);

关于javascript - Internet Explorer 8不允许动态创建按钮,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/11798662/

10-09 01:53