Answer Rocket Hazmat was able to help me in my current project where the cookie value is set, and the row of the table for which this cookie value should be set should be highlighted. The code I originally had was:
$(".datalist TBODY TR:has('TD.itemId:contains(" + activeRowCookie + ")')").attr('id', 'activeRow');
That worked fine until we realized that the table cell might contain the value of activeRowCookie plus other characters, but we need an exact match with all the contents of the cell. In addition, we look for a cell that contains this exact value and no more, but then we select the row in which the cell is located, and not just the cell itself. So I got it to work, adapting the answer here to the following:
$('.datalist TBODY TR TD.itemId').filter(function () { return $(this).text() == activeRowCookie; }).parent().attr('id', 'activeRow');
And yes, this initial selector really needs to be like that, because we donβt want it to look at the cells in the THEAD element.
Christian ziebarth
source share