joetinger
joetinger

Reputation: 2729

Trouble Implementing JQuery Filter

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');

Upvotes: 1

Views: 36

Answers (2)

Ram
Ram

Reputation: 144669

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/

Upvotes: 2

Reece
Reece

Reputation: 396

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

Upvotes: 1

Related Questions