字符转ascii码:用charCodeAt();
ascii码转字符:用fromCharCode();
看一个小例子
复制代码 代码如下:
<script>
str="A";
code = str.charCodeAt();
str2 = String.fromCharCode(code);
str3 = String.fromCharCode(0x60+26);
document.write(code+'<br />');
document.write(str2+'<br />');
document.write(str3);
</script>
输出:
65
A
z
最后
以上就是喜悦鸭子最近收集整理的关于JS中把字符转成ASCII值的函数示例代码的全部内容,更多相关JS中把字符转成ASCII值内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复