Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

177
Visualizações
La oración no se imprime en el navegador

Tengo que intentar examinar y hacer correcciones repetidamente en mi código, pero aún no imprime la oración cuando la ejecuto en el navegador. Todo me parece correcto, pero no tengo idea de por qué la parte 'para.textContent' no se imprime. Los siguientes son mi código:

 <body> <label for="weather"> Select weather type today: </label> <select id="weather"> <option value=""> --Make a choice--</option> <option value="sunny"> Sunny </option> <option value="rainy"> Rainy </option> <option value="snowing"> Snowing </option> <option value="overcast"> Overcast </option> </select> <p></p> <script> const select = document.querySelector('select'); const para = document.querySelector('p'); select.addEventListener('change', setWeather); function setWeather() { const choice = select.value ; switch (choice) { case 'sunny' : para.textContent = 'It is a beautiful day today ! Let\'s go to the park, take a walk outside !'; break; case 'rainy' : para.textContent = 'It\'s rainy outside. Don\'t forget to bring an umbrella if you want to walk outside.; break; case 'snowing' : para.textContent = 'It\'s snowing outside. Just stay at home, sit by the window, sip your tea while reading book and watch outside.' ; break; case 'overcast' : para.textContent = 'It isn\'t raining, but the sky is grey and gloomy, it could turn any minute, so take a rain coat just in case.'; break; default : para.textContent = '''; } } </script> </body>
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

No había utilizado las comillas correctamente, por lo que estaba recibiendo un error. Intente usar comillas dobles "" solo para que el código sea más legible.

 const select = document.querySelector('select'); const para = document.querySelector('p'); select.addEventListener('change', setWeather); function setWeather() { const choice = select.value; switch (choice) { case 'sunny': para.textContent = "It is a beautiful day today ! Let\'s go to the park, take a walk outside !"; break; case 'rainy': para.textContent = "It\'s rainy outside. Don\'t forget to bring an umbrella if you want to walk outside."; break; case 'snowing': para.textContent = "It\'s snowing outside. Just stay at home, sit by the window, sip your tea while reading book and watch outside."; break; case 'overcast': para.textContent = "It isn\'t raining, but the sky is grey and gloomy, it could turn any minute, so take a rain coat just in case."; break; default: para.textContent = ''; } }
 <body> <label for="weather"> Select weather type today: </label> <select id="weather"> <option value=""> --Make a choice--</option> <option value="sunny"> Sunny </option> <option value="rainy"> Rainy </option> <option value="snowing"> Snowing </option> <option value="overcast"> Overcast </option> </select> <p></p> </body>

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda