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

152
Vistas
Data attr in second td is undefined

Content comes from DB. I go foreach on array and insert rows into table. This is the structure of 1 row:

<tr>
    <td data-name = '<?php echo $name ?>'><?php echo $name ?></td>
    <td data-email = '<?php echo $email ?>'><?php echo $email ?></td>
    <td><form method='post'><button class='delete' name='delete' ...>Remove</button></form></td>
<tr>

I am trying to get the content of each data attribute in a row:

 $('.delete').click(function (e) {
        e.preventDefault();
        let name = $(this).parents('tr:first').find('td').data('name');
        let email = $(this).parents('tr:first').find('td').data('email'); // <--- undefined  
        if (confirm(name + ' ' + email + ' delete?')) {
          ...code goes futher...

The question is: I get name value, but email is undefined. What is wrong? I also see the value of email variable in the table and in data attr in dev Console

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