JS 字符/ASCII碼轉換

字符轉ascii碼:用charCodeAt();code

ascii碼磚字符:用fromCharCode();ip

 

看一個小例子ci

<script>it

str="A";co

code = str.charCodeAt();字符

str2 = String.fromCharCode(code);ascii

str3 = String.fromCharCode(0x60+26);script

document.write(code+'<br />');document

document.write(str2+'<br />');

document.write(str3);

</script>

輸出:

65

A

z

相關文章
相關標籤/搜索