原文:JavaScript常用的方法和函數(setAttribute和getAttribute )

僅記錄學習的新知識和示例,無干貨。 .setAttribute和getAttribute Attribute:屬性 setAttribute:為元素添加指定的屬性,並為其賦值 如果指定的屬性已經存在,則僅設置或改變它的值。 調用方法:element.setAttribute attributeName,attributeValue 這是一個方法,無返回值,IE 及以下不支持。 getAttribu ...

2015-08-31 13:35 0 4969 推薦指數:

查看詳情

setAttribute()方法getAttribute() 方法

一、setAttribute() 方法 setAttribute() 方法為一個或一組元素添加指定的屬性,並且為其賦指定的值。(主要針對自定義屬性) 如果這個屬性已經存在,僅僅設置或是修改屬性值。 瀏覽器兼容性:所有主流瀏覽器都兼容 語法: 參數 ...

Sun Dec 08 23:48:00 CST 2019 0 729
setAttributegetAttribute 的用法

setAttribute() 是用於設置自定義屬性的方法,有兩個參數,第一個是屬性名,第二個是屬性值,     添加時必須用引號括起來: 此時的box就加上了一個自定義屬性名和屬性值,可以根據需要賦取 getAttribute 方法用於拿到設置 ...

Wed Jun 24 01:42:00 CST 2020 0 929
關於getAttributesetAttribute(節點屬性)的用法

setAttribute() 方法增加一個指定名稱和值的新屬性,或者把一個現有的屬性設定為指定的值。 語法: elementNode.setAttribute(name,value) 說明: 1.name: 要設置的屬性名。 2.value: 要設置的屬性值 ...

Tue Mar 28 06:32:00 CST 2017 0 1753
setAttribute()方法

setAttribute(string name, string value):增加一個指定名稱和值的新屬性,或者把一個現有的屬性設定為指定的值。 1、樣式問題setAttribute(class, value)中class是指改變class這個屬性,所以要帶 ...

Thu Mar 30 22:56:00 CST 2017 0 5363
 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM