Doubt beginner in javascript conditions

Asked

Viewed 23 times

-3

I would like to know what the error in the code is, I believe, under the conditions, but I do not know.

Thanks in advance!

inserir a descrição da imagem aqui

  • 2

    Please describe what the code should do and don’t put code as an image; the platform has code support.

  • This answers your question? What error in my code?

1 answer

0


To find the input element with the desired value you should search for "input#country" and you’re looking for "input#pais". The "parents" ID element does not exist in the image code you put in the question.

During the rescue of the element of input which has the value you want to verify, you are checking the element against the string Brazil. The correct would be, for both cases:

var country = document.querySelector("input#country")

And on condition, check the value of the element:

if (country.value === "Brasil") {

I hope I’ve helped in some way.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.