7.关于一些dom&&获取元素

1. 测试点击的是否是span 标签

   <span onClick={this.select.bind(this)}>点击</span>

    select( e ){  console.log(e.target.matches(`${'span'}`))  }

注:` `位EMC5字符串模板 `${xx}(${xx})`相当于 var xx , xx + ' ( ' + xx +' ) '

    `${'span'}`表示选择标签名span

2. js的有些获取元素方式没有效果,一下实测有用

  1.) document.getElementById(   )

  2.) document.querySelectorAll(   )

  3.) document.querySelector(   )

原文地址:https://www.cnblogs.com/wangrui38/p/8390959.html