Home  >  Q&A  >  body text

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

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

phpcn_u238phpcn_u2382828 days ago851

reply all(1)I'll reply

  • PHP中文网

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

    获得链接的 target 属性:

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

    结果:

    _blank

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

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


    reply
    0
  • Cancelreply