Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
可能重复: 在 Javascript 中将字符转换为 ASCII 码
如何将任何字符转换为关键代码,例如
m 77 n 78 o 79 p 80 q 81 r 82 s 83 t 84 u 85 v 86
var alphabet = 'abcdefghijklmnopqrstuvwxyz'.split(''), len = alphabet.length, i; for (i = 0; i < len; ++i) { console.log(alphabet[i], alphabet[i].charCodeAt(0) - 32); }
http://jsfiddle.net/zerkms/n2ZFa/