A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://webplatform.github.io/docs/dom/Node/firstChild below:

firstChild ยท WebPlatform Docs

firstChild Summary

Gets a reference to the first child node in the childNodes collection of the object.

If the node is childless, null is returned.

Property of dom/Nodedom/Node

Syntax
var result = element.firstChild;
element.firstChild = value;
Return Value

Returns an object of type ElementElement

Examples

The following code example implements the firstChild attribute to get the first child element of an object.

<body>
<ul id ="oList">
<li>List Item 1</li>
<li>List Item 2</li>
<li>List Item 3</li>
</ul>
<script type="text/javascript">
var oFirstChild = oList.firstChild;
</script>
</body>

The following example shows how the firstChild method will include white space nodes #text.

<p id="para-01">
  First span
</p>
<p id="p2">first span, no whitespace</p>
<script type="text/javascript">
  var p01 = document.getElementById('para-01');
  alert(p01.firstChild.nodeName);
  var p2=document.getElementById('p2');
  alert(p2.firstChild.nodeName);
</script>
Syntax Standards information Attributions

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4