jquery中如何拆分字符串

使用jquery将字符串拆分为数组的方法:split()函数,将字符串分割为子字符串,并将结果作为数组返回,语法:string.split([separator[, limit]])。

具体方法如下:

jquery中可以使用split()函数将字符串拆分为数组.

split()函数作用:

jquery中split()函数的作用是将字符串分割为子字符串,并将结果作为数组返回。

split()函数语法:

string.split([separator[, limit]])


参数:

separator:指定分割字符串的方式。

limit:限制返回数组中的元素个数。

split()函数使用方法:

var str = "hello world!";

var arr;

arr = str.split("");

alert(res); //返回"hello", "world!"


Both comments and pings are currently closed.

Comments are closed.

Powered by KingAbc | 粤ICP备16106647号-2 | Loading Time‌ 0.251