HTML DOM HTMLElement Object

HTMLElement Object

The following collections, properties, and methods can be used on all HTML elements.


HTMLElement Collections

W3C: W3C Standard.

CollectionDescriptionW3C
attributes[]Returns an array of the attributes of an elementYes
childNodes[]Returns an array of child nodes for an elementYes

HTMLElement Properties

PropertyDescriptionW3C
accessKeySets or returns an accesskey for an elementYes
classNameSets or returns the class attribute of an elementYes
clientHeightReturns the viewable height of the content on a page (not including borders, margins, or scrollbars)Yes
clientWidthReturns the viewable width of the content on a page (not including borders, margins, or scrollbars)Yes
dirSets or returns the text direction of an elementYes
disabledSets or returns whether an element is disabled, or notYes
firstChildReturns the first child of an elementYes
heightSets or returns the height attribute of an elementYes
idSets or returns the id of an elementYes
innerHTMLSets or returns the HTML contents (+text) of an elementYes
langSets or returns the language code for an elementYes
lastChildReturns the last child of an elementYes
length Yes
nextSiblingReturns the element immediately following an elementYes
nodeNameReturns the tagname of an element (in uppercase)Yes
nodeTypeReturns the type of the elementYes
nodeValueReturns the value of the elementYes
offsetHeightReturns the height of an element, including borders and padding if any, but not marginsNo
offsetLeftReturns the horizontal offset position of the current element relative to its offset containerYes
offsetParentReturns the offset container of an elementYes
offsetTopReturns the vertical offset position of the current element relative to its offset containerYes
offsetWidthReturns the width of an element, including borders and padding if any, but not marginsNo
ownerDocumentReturns the root element (document object) for an elementYes
parentNodeReturns the parent node of an elementYes
previousSiblingReturns the element immediately before an elementYes
scrollHeightReturns the entire height of an element (including areas hidden with scrollbars)Yes
scrollLeftReturns the distance between the actual left edge of an element and its left edge currently in viewYes
scrollTopReturns the distance between the actual top edge of an element and its top edge currently in viewYes
scrollWidthReturns the entire width of an element (including areas hidden with scrollbars)Yes
styleSets or returns the style attribute of an elementYes
tabIndexSets or returns the tab order of an elementYes
tagNameReturns the tagname of an element as a string (in uppercase)Yes
titleSets or returns the title attribute of an elementYes
widthSets or returns the width attribute of an elementYes

HTMLElement Methods

MethodDescriptionW3C
appendChild()Adds a new child element to the end of the list of children of the elementYes
blur()Removes focus from an elementYes
click()Executes a click on an elementYes
cloneNode()Clones an elementYes
focus()Gives focus to an elementYes
getAttribute()Returns the value of an attributeYes
getElementsByTagName()Accesses all elements with a specified tagnameYes
hasChildNodes()Returns whether an element has any child elementsYes
insertBefore()Inserts a new child element before an existing child elementYes
item()Returns an element based on its index within the document treeYes
normalize()Puts all text nodes underneath this element (including attributes) into a "normal" form where only structure (e.g., elements, comments, processing instructions, CDATA sections, and entity references) separates Text nodes, i.e., there are neither adjacent Text nodes nor empty Text nodesYes
removeAttribute()Removes a specified attribute from an elementYes
removeChild()Removes a child elementYes
replaceChild()Replace a child elementYes
setAttribute()Adds a new attribute to an elementYes
toString()Converts an element to a stringYes

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值