假设我有
var name = "kanishka";
如何只剪切最后一个字符,以便输出为“a”?
我读了问题
How can I cut the 1st char from a string in jquery?
金庸,
in this problem i know the length of the string . can u tell me how i can do this with out knowing the string length .
无法从答案中获得帮助,请帮忙
最佳答案
使用纯 JavaScript,你可以做到
name.charAt(name.length-1)
有关 charAt http://www.w3schools.com/jsref/jsref_charat.asp 的更多信息
关于javascript - 如何从 jquery 中的字符串中删除最后一个字符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5944963/