2012-11-21 54 views
1

動態創建按鈕,然後嘗試將其設置爲button而不是默認的submit設置按鈕的類型,即8

下面是我如何創建按鈕並設置類型。

var pickButton = document.createElement("button"); 
pickButton.type = "button"; 

IE8會報錯了,說:

SCRIPT445: Object doesn't support this action 

回答

2

用途:

pickButton.setAttribute('type', 'button');