Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

157
Vistas
por favor ayúdame javascript > sobre preventDefault
  1. pregunta hola, acabo de entrar en JavaScript En el código de abajo, "preventDefault();" no se pudo ejecutar. Te agradecería mucho si pudieras decirme cuál es el problema. Ingresé el código "preventDefault" pero la página aún se vuelve a cargar. Pensé que lo había escrito bien, pero no sé dónde está el problema.

  2. código ====html====

 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <link rel="stylesheet" href="cstyle.css"> </head> <body> <div class="js-clock"> <h1>00:00</h1> </div> <form action="" class="js-form form showing"> <input type="text" placeholder="What is your name?"></form> <h4 class="js-greetings greetings"></h4> <script src="c.js"></script> <script src="greeting.js"></script> </body> </html>

====js====

 const form = document.querySelector(".js-form"), input = form.querySelector("input"), greeting = document.querySelector(".js-greetings"); const USER_LS = "currentUser", SHOWING_CN = "showing"; function saveName(text) { localStorage.setItem(USER_LS, text); } function handleSubmit(event) { event.preventDefault(); const currentValue = input.value; paintGreeing(currentValue); saveName(currentValue); } function askForName() { form.classList.add(SHOWING_CN); form.addEventListener( 'submit', handleSubmit); } function paintGreeing(text) { form.classList.remove(SHOWING_CN); greeting.classList.add(SHOWING_CN); greeting.innerText = `hello ${text}`; } function loadName() { const currentUser = localStorage.getItem(USER_LS); if (currentUser === null) { // she is not } else { paintGreeing(currentUser); // she is } } function init() { loadName(); } init();
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda