Element Object

Definition and Usage

The Element object represents an element in the HTML document.

The Element object can have child nodes of type Element, Text, Comment, CDATASection, ProcessingInstruction, and EntityReference.

The Element object can have attributes, which have the node type Attr.

Note: The Element object can also use the properties and methods of the Node object.


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The Element object is supported in all major browsers.


Element Object Properties

The "DOM" column indicates in which DOM Level the property was introduced.

Property Description DOM
schemaTypeInfo Returns the type information of the element. 3
tagName Returns the tag name of the element 1

Element Object Methods

The "DOM" column indicates in which DOM Level the method was introduced.

Method Description DOM
getAttribute() Returns the specified attribute value 1
getAttributeNS() Returns the specified attribute value, with the specified namespace. For XML DOM only 2
getAttributeNode() Returns the specified attribute node 1
getAttributeNodeNS() Returns the specified attribute node, with the specified namespace. For XML DOM only 3
getElementsByTagName() Returns a collection of all child elements with the specified tagname 1
getElementsByTagNameNS() Returns a collection of all child elements with the specified tagname and namespace. For XML DOM only 2
hasAttribute() Returns true if the element has the specified attribute, otherwise it returns false 2
hasAttributeNS() Returns true if the element has the specified attribute, with the specified namespace, otherwise it returns false. For XML DOM only 2
removeAttribute() Removes the specified attribute 1
removeAttributeNS() Removes the attribute with the specified name and namespace. For XML DOM only 2
removeAttributeNode() Removes the specified attribute node, and returns the removed node 1
setAttribute() Sets or changes the specified attribute, to the specified value 1
setAttributeNS() Sets or changes the specified attribute, with the specified namespace, to the specified value. For XML DOM only 2
setAttributeNode() Sets or changes the specified attribute node 1
setAttributeNodeNS() Sets or changes the specified attribute node 2
setIdAttribute()   3
setIdAttributeNS()   3
setIdAttributeNode()   3

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值