1

In a Jsp page, I've a ADD button which dynamically adds a text box with id ="email"+rowindex.

When I try to fetch the value of the email added through document.getElementById('email' + (2)).innerText, where (2) is the row index value, it is not working in Firefox, but it works perfectly fine in IE. Please help.

I Hate Lazy
  • 47,415
  • 13
  • 86
  • 77
Saqubar Sadique
  • 105
  • 1
  • 8
  • 1
    [Check this answer](http://stackoverflow.com/questions/1359469/innertext-works-in-ie-but-not-in-firefox). – The Alpha Oct 04 '12 at 13:42

2 Answers2

4

The .innerText property is non-standard. Use .textContent instead.


Or if you're supporting older IE, then you can do it like this:

var email = document.getElementById('email' + 2);

var text = email.textContent || email.innerText;
I Hate Lazy
  • 47,415
  • 13
  • 86
  • 77
0

This little code might be of Help

var email = document.getElementById('email' + (2));
var text = email.value;

Hope this Helps!

Nokia808Freak
  • 903
  • 9
  • 33