REL and CONTAINS Selectors
Hi $("all"),
I've been meddling around with jquery lately and I'm trying to create a system where the user can search a report in table format using a textbox and a dropdown which displays all available column names.
-
$('.report').find('tr').find('td:Contains(' + searchvalue + ')').addClass('highlight').siblings().addClass('highlight');
The above code works perfectly and searches all fields. (Contains is a custom extension which is the same as contains but case-insensitive)
My problem comes in when I'm searching in a particular column. My table has rel values on each TD representing what field they are under (eg. 'First Name' fields have rel="firstname") and this is mapped in the drop down (e.g. <option value="firstname">First Name</option>).
I tried this code here:
-
$('.report').find('tr').find('td[rel=firstname]:Contains(' + searchvalue + ')').addClass('highlight').siblings().addClass('highlight');
This does not work. I tried using has(), moved the [rel=...] selector after the Contains... I'm at a loss.
Can someone please point out the stupid mistake I did? (Coz I'm sure it's a simple thing but I've spent the last hour trying to fix it!)
Cheers.