Possible Duplicate:
Convert character to ASCII code in Javascript
my requirement is to get the ASCII value of the alphabet letters... Can anyone suggest how to do this in JavaScript?
This question is related to
javascript
char
ascii
Here is the example:
var charCode = "a".charCodeAt(0);_x000D_
console.log(charCode);
_x000D_
Or if you have longer strings:
var string = "Some string";_x000D_
_x000D_
for (var i = 0; i < string.length; i++) {_x000D_
console.log(string.charCodeAt(i));_x000D_
}
_x000D_
String.charCodeAt(x)
method will return ASCII character code at a given position.
you can try
"str".charCodeAt(0)
Source: Stackoverflow.com