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

221
Visualizações
Get child element using jquery

I want to get input with class end when the value of class start is changed.

Also I can have more than 1 end and start class

<tr class="input-proporsional">
   <td>1. Start -</td>
   <td>
   <input type="text" name="start[]" class="form-control start" style="width: 60px"> // when the value is changed 
</td>
   <td>End -</td>
   <td>
   <input type="text" name="end[]" class="form-control end" style="width: 60px"> // get this input
</td>
   <td>Rate</td>
   <td><input type="text" name="rate[]" class="form-control rate" style="width: 90px"></td>
</tr>

<tr class="input-proporsional">
   <td>2. Start -</td>
   <td>
   <input type="text" name="start[]" class="form-control start" style="width: 60px"> 
</td>
   <td>End -</td>
   <td>
   <input type="text" name="end[]" class="form-control end" style="width: 60px">
</td>
   <td>Rate</td>
   <td><input type="text" name="rate[]" class="form-control rate" style="width: 90px"></td>
</tr>

So far, I've tried something like code bellow:

$(".start").on("change", function() {
  let element = $(this).parent().parent().find('td').children('end').html();
  console.log(element);
}

But still not working, it return undefined into console. And if write my code like this (up to tr parent):

console.log($(this).parent().parent().html());

The result is like this (I got all of the td):

<td>1. Start -</td>
<td><input type="text" name="start[]" class="form-control start" style="width: 60px"></td>
<t>End -</td>
<td><input type="text" name="end[]" class="form-control end" style="width: 60px"></td>
<td>Rate</td>
<td><input type="text" name="rate[]" class="form-control rate" style="width: 90px"></td>
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

you will have to use .closest()

$(".start").on("change", function() {
  let element = $(this).closest('tr').find('.end').html();
  console.log(element);
}
about 4 years ago · Juan Pablo Isaza Relatório

0

Or you can use parents like:

$(".start").on("change", function() {
  let element = $(this).parents("tr").find(".end");
  console.log(element)
});

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