getAttribute(strAttributeName, lFlags)
取得属性值。
[url]https://msdn.microsoft.com/zh-cn/subscriptions/ms536429.aspx[/url]中介绍了lFlags参数的意义:
0
Default. Performs a property search that is not case-sensitive, and returns an interpolated value if the property is found.
1 strAttributeName大小写完全匹配
Performs a case-sensitive property search. To find a match, the uppercase and lowercase letters in strAttributeName must exactly match those in the attribute name.
2
Returns attribute value as a String. This flag does not work for event properties.
4
Returns attribute value as a fully expanded URL. Only works for URL attributes.
取得属性值。
<div id="div1" class="divname" title="div"></div>
var el = document.getElementById("div1");
alert(el.getAttribute("id"));//div1
[url]https://msdn.microsoft.com/zh-cn/subscriptions/ms536429.aspx[/url]中介绍了lFlags参数的意义:
0
Default. Performs a property search that is not case-sensitive, and returns an interpolated value if the property is found.
1 strAttributeName大小写完全匹配
Performs a case-sensitive property search. To find a match, the uppercase and lowercase letters in strAttributeName must exactly match those in the attribute name.
2
Returns attribute value as a String. This flag does not work for event properties.
4
Returns attribute value as a fully expanded URL. Only works for URL attributes.