--- title: Document.createTextNode() slug: Web/API/Document/createTextNode translation_of: Web/API/Document/createTextNode ---
{{APIRef("DOM")}}

Maakt een nieuwe Text node aan.

Syntax

var text = document.createTextNode(data);

Voorbeeld

<!DOCTYPE html>
<html lang="en">
<head>
<title>createTextNode voorbeeld</title>
<script>
function addTextNode(text) {
  var newtext = document.createTextNode(text),
      p1 = document.getElementById("p1");

  p1.appendChild(newtext);
}
</script>
</head>

<body>
  <button onclick="addTextNode('WIJ KUNNEN HET! ');">WIJ KUNNEN HET!</button>
  <button onclick="addTextNode('WERKELIJK! ');">WERKELIJK!</button>
  <button onclick="addTextNode('GEENSZINS! ');">GEENSZINS!</button>

  <hr />

  <p id="p1">Eerste regel van de paragraaf.</p>
</body>
</html>

Specificaties

Specificatie Status Opmerking
{{SpecName("DOM3 Core", "core.html#ID-1975348127", "Document.createTextNode()")}} {{Spec2("DOM3 Core")}} No change
{{SpecName("DOM2 Core", "core.html#ID-1975348127", "Document.createTextNode()")}} {{Spec2("DOM2 Core")}} Initial definition

Browser compatibiliteit

{{CompatibilityTable}}

Eigenschap Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatUnknown}}
Eigenschap Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}}