如何在JQuery中获取字符串的前三个字母? [英] How can I get the first three letters of a string in JQuery?
本文介绍了如何在JQuery中获取字符串的前三个字母?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在JQuery中获取字符串的前三个字母?
How can I get the first three letters of a string in JQuery?
例如:将cat1234变成cat
For example: Turn cat1234 to cat
推荐答案
无需jQuery!只需使用substring方法:
No jQuery needed! Just use the substring method:
var name = "cat1234"
var variable2 = name.substring(0, 3);
这篇关于如何在JQuery中获取字符串的前三个字母?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文