Link to home
Create AccountLog in
Avatar of Refael
RefaelFlag for United States of America

asked on

jQuery find and contains

Hello Experts,

I am trying to:

1. Find the TD in a table that its text is equal to the "loftNo" variable.
2. Then go to the next TD and grab its text.

Help! Today my brain doesn't work!!!!


$('area').each(function() {
     var loftNo = $(this).attr("id");
    var LoftType = $("td:first:contains("+loftNo+")").next().text();

Open in new window

Avatar of HainKurt
HainKurt
Flag of Canada image

try this:

$("table td[text='" +leftNo + "']").next().text()
ASKER CERTIFIED SOLUTION
Avatar of HainKurt
HainKurt
Flag of Canada image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
just make sure you pass unique values... if you pass "002" and we have 2 td, texts are joined :)
if i change my 3rd row td value to "002" and try that code, I will get "bc"
Avatar of Refael

ASKER

Hi Huseyin KAHRAMAN :-) Thank you.

I think the problem was that i was searching on the first TD only. So I have changed it to "nth-child" and it looks that it is working fine. Yes filter would work better when dealing with duplicate values.
 $("td:nth-child(1):contains("+loftNo+")").next().text(); 

Open in new window

Avatar of Refael

ASKER

Thank you Huseyin KAHRAMAN :-))
oops, my nick should be "HainKurt" :) I made a mistake and put my f&l name somewhere...

fixed it by removing First & Last Name on profile page :)
Avatar of leakim971
please provide a link to your website