Latest web development tutorials

Metoda DOM elementem getAttribute ()

Elementy obiektu obiekt elementu

Przykłady

Uzyskaj kierować linki wartości nieruchomości:

document.getElementsByTagName("a")[0].getAttribute("target");

wyjście:

_blank

Spróbuj »

Definicja i Wykorzystanie

Metoda getAttribute (), aby uzyskać wartość atrybutu po nazwie.

Wskazówka: Jeśli chcesz, aby powrócić użytkowania mienia getAttributeNode metod.


Pomoc Browser

Internet ExplorerFirefoxOperaGoogle ChromeSafari

Metoda Wszystkie główne przeglądarki obsługują getAttribute ()


gramatyka

element.getAttribute( attributename )

parametry

参数 类型 描述
attributename String 必须。你想获取的属性值。

Wartość zwracana

类型 描述
String 指定属性值

dane techniczne

wersja DOM Poziom podstawowy 1 Element obiektu


Elementy obiektu obiekt elementu