火狐-textContent与innerText

document.getElementById('selector').innerText

  火狐不支持innerText,所以设置或者获取数据无法成功

解决方案

  使用textContext属性

document.getElementById('selector').textContent

  但是一些低版本的浏览器不支持textContent这个属性,需要在代码中做兼容,不需要判断浏览器,直接按下面的判断,通过就支持,随便使用页面上的一个元素就可以了。

var support = false;
if(typeof document.getElementById('selector').textContext ==='string'){
        support = true;
}

  

即使是尽在眼前的风景,每踏出一步,都会是一个新世界。
原文地址:https://www.cnblogs.com/blacktusz/p/11454255.html