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

109
Vistas
jquery count 2 values in the table..?

i want to count the value in my table and put the result to a div inside my Html document.

What i have is the following code:

    var counter = 0;
$(document).ready(function(){
    $('Table td').each(function(){
        if ($(this).text() === "Nicht aktiv") counter++; 
        $("#log2").html("Nicht in Arbeit " + counter);
    });
});

I want to check:

if this text === "Nicht aktiv" and if this text in another td is Test1

Jquery or Javascript are not my main languages so i dont know, how i can solve this..

I hope you guys can help me.. :)

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You likely mean

$(function() {
  const counter = $('table td')
    .filter(function() {
      return $(this).text() === "Nicht aktiv" &&
        $(this).siblings().filter(function() {
          return $(this).text() === "Test1"
        }).length > 0;
    }).length
  $("#log2").html("Nicht in Arbeit " + counter);
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<span id="log2"></span>
<table>
  <tr>
    <td>Nicht aktiv</td>
    <td>Bla</td>
    <td>Test1</td>
  </tr>
  <tr>
    <td>Nicht aktiv</td>
    <td>Bla</td>
    <td>Test2</td>
  </tr>
  <tr>
    <td>Nicht aktiv</td>
    <td>Bla</td>
    <td>Test1</td>
  </tr>
  <tr>
    <td>Nicht aktiv</td>
    <td>Bla</td>
    <td>Test2</td>
  </tr>
  <tr>
    <td>Nicht aktiv</td>
    <td>Bla</td>
    <td>Test1</td>
  </tr>
</table>

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