-1
I’m trying to do a basic validation in pure javascript.
works as follows;
I have a <h1>
where the user profile is informed and I need to check the text, as an example:
<h1 class="perfil-usuario">SISTEMA<h1>
And I also have the condition:
<script>
var perfilSistema = document.querySelector(".perfil-sistema");
if (perfilSistema == 'SISTEMA' ) {
window.location = "index.html";
}
</script>
But it is not directing the user to the index when it receives SYSTEM. Grateful to those who help.
It even worked @Renan, but the class has no mandatory standard no. You’re kind of wrong about that
– Francis Vagner da Luz
@Francisvagnerdaluz did not say that it is mandatory, I said that your consultation is wrong.
– Renan Gomes
My consultation?
– Francis Vagner da Luz
@Francisvagnerdaluz
<h1 class="perfil-usuario">...<h1>
document.querySelector(".perfil-sistema")
.– Renan Gomes
Now that I understood.. It was just an example, just as it was written there in the question. Examples are not real. Where I am programming is right
– Francis Vagner da Luz
@Renan probably by
SISTEMA<h1>
be closed incorrectly, should be</h1>
, thetextContent
may be bringing something else, even spaces or break lines.– Guilherme Nascimento
@Francisvagnerdaluz On the name of the classes according to the question presented, it must contain the real code of the problem, to avoid that the answers are taken on unreal problems.
– Guilherme Nascimento