ví dụ
RUN
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> </head> <body> <h1>Học lập trình miễn phí tại freetuts.net</h1> <button onclick="myFunction()">Run</button> <p id="demo"></p> <script> function myFunction() { var str = "Freetuts.net"; var content = ''; var len = str.length; content = content + 'Vị trí đầu tiên - ' + str.charCodeAt(0) + '<br>'; content = content + 'Vị trí thứ 2 - ' + str.charCodeAt(1) + '<br>'; content = content + 'Vị trí thứ 3 - ' + str.charCodeAt(2) + '<br>'; content = content + 'Vị trí thứ 4 - ' + str.charCodeAt(3) + '<br>'; document.getElementById("demo").innerHTML = content; } </script> </body> </html>
PHÓNG TO