polilop wrote:
How can i get value of a td in a table?
I tried
tabl=document.getElementById("table").rows[0].innerText;
but this is only supported by iexplorer.
I guess you are after the text in the node with any HTML tags stripped
out. The following function uses W3C DOM 3 textContent or innerText or
recurses through the child nodes grabbing the text.
You may want to modify it to deal with other node types.
function getElText(el)
{
if (el.textContent) return el.textContent;
if (el.innerText) return el.innerText;
var x = el.childNodes;
var txt = '';
for (var i=0, len=x.length; i<len; ++i){
if (3 == x[i].nodeType) {
txt += x[i].data;
} else if (1 == x[i].nodeType){
txt += getElText(x[i]);
}
}
return txt.replace(/\s+/g,' ');
}
--
Rob