Reputation: 191
Hello, how do I hide the checkbox for the table row that always contains the word "Fixed" as a link? Please see screenshot. The ID and names are dynamic and always change. I tried this but had no luck:
$( "tr:contains('Fixed')" ).find( ":checkbox" ).css( "display", "none" );
Upvotes: 0
Views: 197
Reputation: 547
$( "tr a:contains('Fixed')" ).find( ":checkbox" ).css( "display", "none" );
Upvotes: 0
Reputation: 15802
Something like this should work:
$('a').filter( function() {
return ~$(this).text().toLowerCase().indexOf('fixed');
} ).closest('tr').find(':checkbox').hide();
The .toLowerCase()
makes it case-insensitive, and the ~
is there because if indexOf()
doesn't match the string, it returns -1 (0 means "at position 0"), so the bitwise NOT converts -1 into the falsey value of 0, and everything else into truthy values.
You can improve this by adding a selector to the front so it doesn't crawl every single <a>
tag - something like $('table').find('a')
or better yet the ID, or something more identifiable.
Upvotes: 2