'innerText' works in IE, but not in Firefox

前端 未结 15 1402
执念已碎
执念已碎 2020-11-21 05:01

I have some JavaScript code that works in IE containing the following:

myElement.innerText = \"foo\";

However, it seems that the \'innerTex

15条回答
  •  悲&欢浪女
    2020-11-21 05:29

    A really simple line of Javascript can get the "non-taggy" text in all main browsers...

    var myElement = document.getElementById('anyElementId');
    var myText = (myElement.innerText || myElement.textContent);
    

提交回复
热议问题