DEV Community

Alexandre Freire
Alexandre Freire

Posted on

How to add text to an HTML element with JS

In this example, we will change the text in the 'th' element

...
<th id="dt_emissao"></th>
...
Enter fullscreen mode Exit fullscreen mode
var dt_emissao = document.getElementById("dt_emissao");
dt_emissao.textContent = "Example";
Enter fullscreen mode Exit fullscreen mode

Top comments (0)