<table>
  <tr>
    <td  onclick="getDetail(this)">zhangtongzct</td>
  </tr>
</table>

  通过点击table中td,获取td中的值,在一般浏览器,ie,360,谷歌中都支持innerText,但是火狐支持innText

火狐中要用textContent,所以代码我们应该这样写

        function getDetail(obj){
            var str= obj.innerText;
            if( str == null ) str = obj.textContent ; // 兼容火狐
            return str;
        }

 

相关文章:

  • 2022-02-04
  • 2022-02-11
  • 2021-10-07
  • 2022-02-15
  • 2022-12-23
  • 2021-07-28
  • 2022-03-04
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-20
  • 2021-10-26
相关资源
相似解决方案