innerText May Not Work On Mozilla Firefox
Posted by in Javascript March 1, 2012 1 Comment

I have a span HTML object, I try to use getElementById and innerText to set the text between the start and end of the object. It works fine on IE, Google Chrome and Safari but it doesn’t work Firefox.

For example:

+ HTML object:

<span id="intro"></span>

+ getElementById and innerText:

<script language="javascript">
document.getElementById("intro").innerText = "4 Rapid Development"; 
</script>

The piece of JavaScript above doesn’t work on Firefox but when I try with innerHTML, it works :)

<script language="javascript">
document.getElementById("intro").innerHTML = "4 Rapid Development"; 
</script>

Hope the simple post helps someone!

Hoan Huynh is the founder and head of 4rapiddev.com. Reach him at hoan@4rapiddev.com
  • quynh nguyen

    Hi Hoan, in Firefox, using “textContent”  is also ok :) !
    document.getElementById(“intro”).textContent= “4 Rapid Development”;