0

enter image description here

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" );
3
  • Inspections are hardly readable. But did you try .css( {"display": "none" }) Commented Nov 7, 2014 at 16:09
  • Would not it be better to put the disabled attribute on the checkbox? Commented Nov 7, 2014 at 16:16
  • Posting a zoomed-out partial screenshot of a section of your code in the inspector is not a useful way to show us the code you're working with. You need to post the relevant code in the question. Commented Nov 7, 2014 at 20:56

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Sorry to ask, but what does the :checkbox CSS selector look for? A type? I tried googling it for for selecting types I only found element[type=...] like examples.
@AlejandroIván it's a jQuery selector, not a CSS one - see the docs
0

$( "tr a:contains('Fixed')" ).find( ":checkbox" ).css( "display", "none" );

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.