火狐-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;
}

  

posted @ 2019-09-03 17:16  Black兔斯基  阅读(168)  评论(0编辑  收藏  举报