textContent vs innerHTML in the JavaScript DOM

Veröffentlicht am: 22 Juni 2018
auf dem Kanal: dcode
56,046
972

Although commonly used interchangeably, there is a major difference between the textContent and innerHTML properties when working with Elements in JavaScript, and it's important you know what that is.

The major difference is that when using the innerHTML property, the client browser will actually interpret the content as HTML markup, and apply that change to the DOM/Window. On the other hand, the textContent property will only change the the text, preserving any HTML markup.

In this video I take you through a basic example to demonstrate that difference.

Support me on Patreon:
  / dcode   - with enough funding I plan to develop a website of some sort with a new developer experience!

For your reference, check this out:
https://developer.mozilla.org/en-US/d...
https://developer.mozilla.org/en-US/d...

Follow me on Twitter @dcode!

If this video helped you out and you'd like to see more, make sure to leave a like and subscribe to dcode!


Auf dieser Seite können Sie das Online-Video textContent vs innerHTML in the JavaScript DOM mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer dcode 22 Juni 2018 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 56,046 Mal angesehen und es wurde von 972 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!