问题比较简单,直接上代码:

var str = "abc";
alert(str[0]);
alert(str.charAt(0));
 
测试结果:
firefox:a,a
chrome:a,a
ie9:a,a
ie8:a,a
ie7:undefined,a
ie6:undefined,a
 
总结:获取字符串指定位置的字符,需用charAt,除非不考虑兼容ie6、ie7

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-09-20
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-30
  • 2021-11-20
相关资源
相似解决方案