Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

111
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!