I use the following script for get the values from HTML Table.If I use innerText ,It will work on IE and Chrome Fine.But FireFox show the Error: row.cells[0].innerText is undefined Source.If I use textContent It will work Fine in Chrome and FireFox.But IE Shows the Following Error cells.0.textContent’ is null or not an object.How to change this script Work on IE,Chrome,FireFox without Error? I use either c= row.cells[0].innerText.strip();or c=row.cells[0].textContent.strip();
function a()
{
var table = getServerObject("b");
var row,c;
for (var i = 2; i < table.rows.length - 1; i++)
{
row = table.rows[i];
if(row.cells.length==1)continue;
c= row.cells[0].innerText.strip(); //It was work in chrome and IE (or)
c=row.cells[0].textContent.strip();//It was work in chrome and FF
if(c==0)
{
//Something
}
}
}
Just test before using the property, which is available:
Later on you have a if to decide, which property to use
or shorter as suggested by @RobW
For the slight differences between both properties note the following from the MDN docu on
textContent: