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

154
Visualizações
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 à 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