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

209
Vistas
Why I am getting Undefined Value when I click on image ? How to fix this?

I am getting this error (undefined) when I am clicking on image to get the value of image. Can you please explain the reason behind it and how to get and pass the value to onclick function in this case.

      <div id="fi" value="0">
        <img src="first.JPG" alt="first" id="first" value="01" onclick="checkingg(this.value)"/>
      </div>

      // inside script tag
      function checking(img_val) {
        console.log(img_val);
      }
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

No problem in your approach, except value is not a valid attribute on image and hence will be undefined. Use custom data attributes data-*:

      function checking(img_val) {
        console.log(img_val);
      }
  <div id="fi" value="0">
        <img src="https://media.istockphoto.com/photos/analyzing-samples-in-test-tube-backgrounds-picture-id1290116527?b=1&k=20&m=1290116527&s=170667a&w=0&h=51bfejWaiLIK8ZeeP7u7q0b1UINUwx3dbH86HZNNuPA=" alt="first" id="first" data-value="01" onclick="checking(this.dataset.value)"/>
      </div>

about 4 years ago · Juan Pablo Isaza Denunciar
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