innerText not working in Firefox

Blease picture Blease · Oct 15, 2012 · Viewed 7.5k times · Source

This is my code:

<div id="code">My program<br />It is here!</div>
<script type="text/javascript">
var program=document.getElementById('code');
ShowLMCButton(program.innerText);
</script>

It works in IE but in firefox, innerText does not work. How can I use this in firefox? I have tried .text() but it doesn't want to work! I need the text to be in the form "My program\n It is here!"

What this is, is to copy a VB script from a site and paste it straight into a program and it must include all the new lines etc.

Answer

h2ooooooo picture h2ooooooo · Oct 15, 2012

You used the tag , so I assume that you use jQuery. Hence you have to refer to the jQuery object and not the HTMLObject.

<div id="code">My program<br />It is here!</div>
<script type="text/javascript">
    var program = $('#code');
    ShowLMCButton(program.text());
</script>