HTML DOM getAttribute() ·½·¨
ʵÀý
»ñµÃÁ´½ÓµÄ target ÊôÐÔ£º
document.getElementsByTagName("a")[0].getAttribute("target");
½á¹û£º
_blank
¶¨ÒåºÍÓ÷¨
getAttribute() ·½·¨·µ»ØÖ¸¶¨ÊôÐÔÃûµÄÊôÐÔÖµ¡£
Ìáʾ£ºÈç¹ûÄúÏ£ÍûÒÔ Attr ¶ÔÏó·µ»ØÊôÐÔ£¬ÇëʹÓà getAttributeNode¡£
ä¯ÀÀÆ÷Ö§³Ö
| IE | Firefox | Chrome | Safari | Opera |
|---|---|---|---|---|
ËùÓÐÖ÷Á÷ä¯ÀÀÆ÷¾ùÖ§³Ö getAttribute() ·½·¨¡£
Óï·¨
element.getAttribute(attributename)
²ÎÊý
| ²ÎÊý | ÀàÐÍ | ÃèÊö |
|---|---|---|
| attributename | ×Ö·û´®Öµ¡£ | ±ØÐè¡£ÐèÒª»ñµÃÊôÐÔÖµµÄÊôÐÔÃû³Æ¡£ |
·µ»ØÖµ
| ÀàÐÍ | ÃèÊö |
|---|---|
| String | Ö¸¶¨ÊôÐÔµÄÖµ¡£ |
¼¼Êõϸ½Ú
| DOM °æ±¾ | Core Level 1 Element Object |