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.
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> </td><td> </td>
<td> 0:0 </td><td> </td>
</tr>
<tr>
<td> </td><td> </td>
<td>123//</td><td> </td>
</tr>
<tr>
<td> </td><td> </td>
<td>/ 0:0</td><td> </td>
</tr>
<tr>
<td> </td><td> </td>
<td>0:0</td><td> </td>
</tr>
<tr>
<td> </td><td> </td>
<td>0:0/</td><td> </td>
</tr>
</table>