1

I have some JQuery that filters a table when the select list is changed using :contains but because two of the options are so similar it doesn't filter correctly. Here is a functional JSFiddle. I tried implementing a .filter but I obviously am doing something wrong. Here is the JSFiddle

Current .filter

$(this).filter(function(){
    return $(this).text===selectValue;
}).addClass('hidden');
0

2 Answers 2

2

text is a method not a property, you are comparing the text function's body with the selected value. According to your markup I would suggest:

$("#filterItems .hideThis").addClass('hidden').filter(function() {
    return $('td:eq(3)', this).text() === selectValue;
}).removeClass('hidden');

Note that you can also use the jQuery's show and hide methods instead of adding/removing classes.

http://jsfiddle.net/24eTW/

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

1 Comment

Thank you that is pretty great!
1

use $(this).text() to get the value, just using the handler without the parantheses will return the function rather than executing it

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.