How to pull a value from a table stored in an html table via Jquery searching through columns and rows


Goal: Take a var called $item which is html containing a table with information about a specific item. Search down the first column of the table and find a substring that is provided in variable $ModelName. Record the table row number in which it is found. Then search each table header (th) to find one that matches the string "length". Record that column number. Now go to the table row number you previously recorded in that column and save that value in a variable called $endProduct Done.

I think this should find the ModelName and provide me the tablerow, but it does not work.

 var $item = $(stuff).closest("tr").find("td:contains(ModelName)").text();

Next I need to find the column with the word "length" in it and record the column number. I'm guessing the code could be similar to the above if actually worked like: var $item = $(stuff).find("th:contains("length")").text();

Then to retrieve the end product:

$endProduct = ???????????

Should I be using .filter() instead?

Show source
| jquery   | find   2017-01-04 17:01 0 Answers

Answers ( 0 )

◀ Go back