textContent vs innerHTML in the JavaScript DOM

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:
– with enough funding I plan to develop a website of some sort with a new developer experience!

For your reference, check this out:

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!

Nguồn: https://dinhk.net/

Xem thêm bài viết: https://dinhk.net/category/giai-tri/

No Tag

10 Responses

  1. Shayn Hacker says:

    Can you send a value like this 18.4983552,-77.8715136 to an input tag?

  2. Charles Hudson says:

    Great explanation, keep the good work.
    P.S: I subscribed and liked the video

  3. inferno 03 says:

    very good ❤

  4. Aditya Srivastava says:

    My code is not working how can I get a help from you. Please help me sir

  5. Chukonu5 says:

    What keyboard/switches are you using? Sounds good.

  6. George Columbu says:

    thanks you've been so helpfull, you have no idea

  7. westfield90 says:

    Thank you for explaining it so well.

  8. HamiD chawn says:

    Thank you SO MUCH !!!!!!!!!!!! 😭😭😭

  9. Creative UK says:

    Great video. Did not know about the security aspect of innerHtml.

  10. Man-on-the-Run says:

    The interesting part is the subtle difference between textContent and innerText.
    Could you make a video on that ? …

Leave a Reply

Your email address will not be published. Required fields are marked *

Dự đoán xổ số