charAt()和charCodeAt()

var str = "hello world";

document.write(str[1]);   //输出结果e     ie7前的浏览器不兼容

document.write(str.charAt(0));   //输出结果h  兼容浏览器

document.write(str.charCodeAt(4));   //输出结果111  返回o字符串的编码

posted @ 2018-09-18 23:43  键1234  阅读(986)  评论(0编辑  收藏  举报