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

103
Views
jQuery to delete hide table row if based on contents of two cells within row

I'm trying to write a script for tampermonkey that hides a row in a table based on two conditions.

Condition 1: The cell in column 3 doesn't contain '/'

Condition 2: the cell in column 3 does contain '0:0'

I've got condition 1 working on its own with the following jQuery

$("td:nth-of-type(3):not(:contains('/'))").parent ().hide ();

and condition 2 with

$("td:nth-of-type(3):contains('0:0')").parent ().hide ();

but I haven't been able to combine them, I've tried the following:

$("[td:nth-of-type(3):contains('0:0')][td:nth-of-type(3):not(:contains('/'))]").parent ().hide ();

but no luck. How can I combine the conditions? I've tried to include an if statement but haven't been able to get that working either.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You were heading in the right direction. Keep chaining the :contains and :not(:contains(...)) calls.

Try the runnable example below, note that the 1st and 4th rows are hidden.

$("td:nth-of-type(3):contains('0:0'):not(:contains('/'))").parent().hide();
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<table border="1">
<tr>
  <td>&nbsp;</td><td>&nbsp;</td>
  <td> 0:0 </td><td>&nbsp;</td>
</tr>
<tr>
  <td>&nbsp;</td><td>&nbsp;</td>
  <td>123//</td><td>&nbsp;</td>
</tr>
<tr>
  <td>&nbsp;</td><td>&nbsp;</td>
  <td>/ 0:0</td><td>&nbsp;</td>
</tr>
<tr>
  <td>&nbsp;</td><td>&nbsp;</td>
  <td>0:0</td><td>&nbsp;</td>
</tr>
<tr>
  <td>&nbsp;</td><td>&nbsp;</td>
  <td>0:0/</td><td>&nbsp;</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!