日期:2014-05-16  浏览次数:20390 次

简单的js字符串分割问题求教
比如我传一个坐标参数到js中,怎么分割呢?
把两个值分割到x,y中
the的值是坐标,118.517679,31.706102

JScript code

function maker(the){
     var point=the; 
     x=
     y=



------解决方案--------------------
function maker(the){
var point=the; 
x=point.split(",")[0];
y=point.split(",")[1];

------解决方案--------------------
var result = the.split(",");
for(var i=0;i<result.length;i++){
alert(result[i]);//这个就是截出来的值,可以x=result[0],y=result[1]取值。
}