js_property.md - brainchildservices/curriculum GitHub Wiki

Slide 1

JAVASCRIPT .textcontent PROPERTY

  • The textContent property sets or returns the text content of the specified node, and all its descendants.
  • If you set the textContent property, any child nodes are removed and replaced by a single Text node containing the specified string.
  • This property is similar to the innerText property, however there are some differences:
    • textContent returns the text content of all elements, while innerText returns the content of all elements, except for <script> and <style> elements.
    • innerText will not return the text of elements that are hidden with CSS (textContent will)
    • To set or return the HTML content of an element, use the innerHTML property.

Slide 2

JAVASCRIPT .value PROPERTY

  • The value property sets or returns the value of the value attribute of a text field.

  • The value property contains the default value OR the value a user types in (or a value set by a script).

  • Syntax:

  • textObject.value [Return the value property]

  • textObject.value = text [Set the value property]

⚠️ **GitHub.com Fallback** ⚠️