HTML DOM setAttribute() 方法
實例
設置 input元素的的屬性類型:
	document.getElementsByTagName("INPUT")[0].setAttribute("type","button");
	設置屬性前:
設置屬性後:
定義和用法
setAttribute() 方法創建或改變某個新屬性。
如果指定屬性已經存在,則只設置該值。
流覽器支持





所有主要流覽器都支持 setAttribute() 方法
Internet Explorer 8 及更早 IE 版本不支持該方法。
語法
element.setAttribute(attributename,attributevalue)
參數
| 參數 | 類型 | 描述 | 
|---|---|---|
| attributename | String | 必須。你要添加的屬性名稱。 | 
| attributevalue | String | 必須。你要添加的屬性值。 | 
返回值
沒有返回值。
技術細節
| DOM 版本 | Core Level 1 Element Object | 
|---|

 元素對象
 元素對象