简体   繁体   中英

JavaScript code not working in Firefox while working very well in other broswers

I have programmed a script-- First I have created a <div>....</div> which is hidden on pageload. Then I have created an empty textbox. Now when anyone clicks a button then the whole content of the hidden <div>....</div> will be loaded in the textbox. Heres the code of it:

<div id="hiddendiv" style="display: none;">some content</div>
<button onclick="copyfunction();">click me</button>
<textarea id="textarea"></textarea>

<script>
function copyfunction() {
var textarea = document.getElementById('textarea');
var hiddendiv = document.getElementById('hiddendiv');
textarea.value = hiddendiv.innerText;
}
</script> 

This JavaScript is working fine on my webpage when i am viewing it on any other browser. But when viewed in firefox, the textbox shows "undefined" as the output when the button is clicked. Note: All Java Add-ons are enabled and up to date. Even tried clearing all cookies but it didn't help.

FF中没有innerText ,而是textContent

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM