开发者

How can I cut the 1st char from a string in jquery?

开发者 https://www.devze.com 2023-03-04 08:16 出处:网络
Does anyone know how can I cut the 1st char from the string in jquery? Example: If I have string as following:

Does anyone know how can I cut the 1st char from the string in jquery?

Example: If I have string as following:

var test = '32开发者_开发百科65';

How can I cut only the 1st char so that the output will be '3' instead?


Why jQuery?? Just use plain old javascript:

var first = test.substring(0, 1)


No need for jQuery, straight javascript:

var test = '3265'
var first = test.slice(0,1);

Some thoughts on the differences between .substring(), .substr() and .slice() : http://rapd.wordpress.com/2007/07/12/javascript-substr-vs-substring/

also: What is the difference between String.slice and String.substring?


Array.prototype.shift.apply(test);
0

精彩评论

暂无评论...
验证码 换一张
取 消