1
<p id="demo">单击按钮显示字符串的第一个字符的编码。</p>
2
<button onclick="myFunction()">点我</button>
3
<script>
4
function myFunction() {
5
var str = "HELLO WORLD";
6
var n = str.charCodeAt(0);
7
document.getElementById("demo").innerHTML = n;
8
}
9
</script>