laredotornado <la***********@zipmail.comwrites:
If I have a TD, whose id = "myTd," that only contains text within
it,how do extract that text?
Find all child nodes that are text nodes, and extract their content.
Even if the td only contains text, that text might be split over
more than one text node (worst case).
var td = document.getElementById("myTd");
var textNodeContents = [];
for(var chld = td.firstChild; chld; chld = chld.nextSibling) {
if (chld.nodeType == 3) { // text node
textNodeContents.push(chld.nodeValue);
}
}
var text = textNodeContents.join("");
/L
--
Lasse Reichstein Nielsen
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'