views:

22

answers:

1

Hi, I am using the following code to retrieve the content of a cell in the table. This works fine in Mozilla Firefox. But, its not working in IE. Any suggestions??

var langName = tblCells[1].textContent.trim();

The error message is:

1.textContent is null or not an object
+1  A: 
function text ( el ) {
   return el.textContent? el.textContent : el.innerText;
}

Use however you like. IE uses innerText.

meder
Hi meder,How should I call this function? Element el = tblCells[1]; var langCode = text(el).trim();I have tried this way. Its not working.
Rajkumar
Pass the DOM element to it. `var theText = text( tblCells[1] );`
meder
Hi Meder, its working now. I have one more question. I have tables with textboxes in the table cells. How could I retrieve the values of those textboxes? Thanks in Advance.
Rajkumar
the value attribute? you mean input?
meder
I have tried it now. Its working fine. The code I use is:var set2 = tblcells[3].firstChild.value.trim();I have a query to you on commenting. How could I show code in codeblocks in comments?
Rajkumar