设置按钮的类型,ie8

时间:2012-11-21 03:50:48

标签: internet-explorer-8

动态创建按钮,然后尝试将其设置为button,而不是默认submit

以下是我创建按钮和设置类型的方法。

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

IE8会出错,说:

SCRIPT445: Object doesn't support this action 

1 个答案:

答案 0 :(得分:2)

使用:

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