当前位置: 代码迷 >> JavaScript >> 简单的js字符串分割有关问题求教
  详细解决方案

简单的js字符串分割有关问题求教

热度:85   发布时间:2012-09-11 10:49:03.0
简单的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]取值。
}
  相关解决方案