Heim  >  Fragen und Antworten  >  Hauptteil

为什么这里不能通过getAttribute()方法获取nodeName属性值?

为什么这里不能通过getAttribute()方法获取nodeName属性值?

phpcn_u238phpcn_u2382828 Tage vor852

Antworte allen(1)Ich werde antworten

  • PHP中文网

    PHP中文网2016-12-23 10:03:07

    获得链接的 target 属性:

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

    结果:

    _blank

    getAttribute() 方法返回指定属性名的属性值。

    提示:如果您希望以 Attr 对象返回属性,请使用 getAttributeNode。


    Antwort
    0
  • StornierenAntwort