可以用字符串替换函数replace吧,
str="1831,1829,1812,1829,134,171";
str=str.replace("1812,","");
至于去掉首尾,我想到的方法就是先用“,”截取字符串到数组里,去掉首尾,然后再整合成字符串:
var a=str.split(",");
for(i=1;i<a.length-1;i++)
{
b[i-1]=a[i];
}
c=b.join(",");
str="1831,1829,1812,1829,134,171";
str=str.replace("1812,","");
至于去掉首尾,我想到的方法就是先用“,”截取字符串到数组里,去掉首尾,然后再整合成字符串:
var a=str.split(",");
for(i=1;i<a.length-1;i++)
{
b[i-1]=a[i];
}
c=b.join(",");