Passing a variable to: contains a selector

window.something.updateStatus = function(theName) { $('#myTable').children('tr').remove(":contains('theName')"); }; 

Obviously, this does not work, because it searches for a string called "theName" in any of myTable.

What I would like to do is pass the Name value to the contained ones.

How to evaluate this expression?

Thanks.

+4
source share
1 answer

This is not tested, but should work:

 window.something.updateStatus = function(theName) { $('#myTable').children('tr').remove(":contains('" + theName +"')"); }; 

In fact, it removes theName variable from the string, but still quotes this value (after interpolating the variable), therefore there is an opening and closing ' on each side of the variable and + concatenation operators.

+9
source

All Articles