[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2133
  • Last Modified:

Need to get <TD> value without a ID in the tag.

I have a <Table> with no ID and a <TD> with no ID and I have the following I need to be able to get the value from. I did not write the HTML nor can I change it, I'm using grease monkey on FF so I can make some changes to a website.

<td>157</td>
0
thaburner
Asked:
thaburner
  • 2
1 Solution
 
flipzCommented:
You can use something like this:

var arrCells = document.getElementsByTagName('td');
for (idx=0;idx<arrCells.length;idx++) {
  strValue = arrCells[idx].innerHTML;
  alert(strValue);
}

The problem is this will give you the contents of every TD element on the page. You would need some identifiable property to distinguish which one you are looking for.
0
 
tchamtiehCommented:
Use something like this in your jscript code.
var elTableCells = elTableRow.getElementsByTagName("td");
alert(elTableCells[0].innerText);

Open in new window

0
 
thaburnerAuthor Commented:
flips I think that will do the trick because it will always be 11th in spot

if (idx==11){
   alert(strValue);
}

Thanks
0
 
flipzCommented:
No problem - glad to help.
0

Featured Post

2018 Annual Membership Survey

Here at Experts Exchange, we strive to give members the best experience. Help us improve the site by taking this survey today! (Bonus: Be entered to win a great tech prize for participating!)

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now