I have the following table structure
<table class="ms-listviewtable>
<tr>
<td class="ms-vb2-icon"/>
<td class="ms-vb2"/>
<td class="ms-vb2"/>
<td class="ms-vb2"/>
<td class="ms-vb2"/>
<td class="ms-vb2">test1</td>
</tr>
<tr>
<td class="ms-vb2-icon"/>
<td class="ms-vb2"/>
<td class="ms-vb2"/>
<td class="ms-vb2"/>
<td class="ms-vb2"/>
<td class="ms-vb2">test2</td>
</tr>
<tr>
<td class="ms-vb2-icon"/>
<td class="ms-vb2"/>
<td class="ms-vb2"/>
<td class="ms-vb2"/>
<td class="ms-vb2"/>
<td class="ms-vb2">test3</td>
</tr>
</table>
I need to loop through each row then loop through each td and check if a td in a row contains the text ‘test1’ if so I need hide the td with class “ms-vb2-icon” within the same row.
Can someone please give me some pointers?
You can do it like this:
You can test the code against your markup here
This uses
:contains()to see if a<td>contains that text, wrapped in:has()to see if the the<tr>has an element matching that, the next we’re finding thetd.ms-vb2-iconcell in the matched rows and hiding them.