Hello, I'm not sure what to do, but I'm not sure how to do this. for example "Hello world!" remembering that this variable will then automatically change out of consideration for a fixed value.
<div><p >Imprimir aqui</p></div>
Hello, I'm not sure what to do, but I'm not sure how to do this. for example "Hello world!" remembering that this variable will then automatically change out of consideration for a fixed value.
<div><p >Imprimir aqui</p></div>
Never forget to use window.onload
to be able to run your JavaScript
code after HTML elements are ready to be manipulated.
I've created an example for you to see the change in real time.
window.onload = function() {
var myvar = "Olá mundo";
document.getElementById("mydiv").innerHTML = myvar;
setInterval(function() {
if (myvar == "Olá mundo") {
myvar = "Mudando dinamicamente"
} else {
myvar = "Olá mundo"
}
document.getElementById("mydiv").innerHTML = myvar;
}, 2000);
}
<div id="mydiv"></div>
I hope I have helped.