Your code should be:
function nome () {
var tela = document.createElement('div')
tela.setAttribute('id', 'screen')
document.body.appendChild(tela)
}
nome()
This is because the value of the screen variable does not have a correct type (expected Htmldivelement) so that it can be injected into the GIFT. In other words, the method setAttribute() returns "void".
In fact, CSS is not applying to your DIV element because it doesn’t exist, because of the wrong instruction.
When you do:
var tela = document.createElement("div").setAttribute("id","screen");
You actually create the DIV, but it’s still not in the DOM.
And here you try to inject it into the DOM, but by the fact of the variable tela
have a value "nothing" (Undefined), this DIV is never placed in your HTML document:
document.body.appendChild(tela); // essa linha não faz sentido
What do you mean ? I didn’t know that.
– Daniel Santos
I must have written something off the chart on this var?
– Daniel Santos
I’ll see that, thanks for the help felipsmartins
– Daniel Santos
@Danielsantos, look at the issue that explains why.
– felipsmartins
I was able to solve it, it was a very simple error,.
– Daniel Santos
was a wrong turn
– Daniel Santos
so it said that the variable did not have a nodename
– Daniel Santos
he had to load the page body first, and not the external script because then the copier would not even know where to place the div,and so in fact the variable would have no value at all,.
– Daniel Santos
took long but I found
– Daniel Santos
thanks friend for the message about the possible error,helped me a lot I did a research on this node and found out why
– Daniel Santos