作者No (you stay there)
看板Ajax
标题Re: [问题] setAttribute一串参数
时间Thu Sep 22 19:29:25 2011
※ 引述《robinnpca (rob)》之铭言:
: 我的程式如下
: var Boxs;
: var ppAry = new Array(); //宣告变数ppAry是阵列//
: Boxs=Rect.getAttribute("Box");
: /要取Box里面的参数共有四组用空格分开例如 Box="0 0 100 100"/
: ppAry=Boxs.split(" ");//用空格分开//
: 但是问题来了
: 1.取到的数字变成了字串 不能进行运算
: 我目前是用
: ppAry0=parseInt(ppAry[0]);
: ppAry1=parseInt(ppAry[1]);
: ppAry2=parseInt(ppAry[2]);
: ppAry3=parseInt(ppAry[3]);
: //转成整数数字//
: 问:有没有较简便的方式使他取出来的不是字串
: 可以直接是数字 不用这样一个个转换
ppAry = Boxs.split(" ").map(function(value){
return parseInt(value, 10);
});
: 2.想要将运算後的Box参数放回去在
: function ()
: {
: Rect.setAttribute("Box", "ppAry");
: //都会失败>__<//
: }
Rect.setAttribute("Box", ppAry.join(' '));
: //我用alert都只显出ppAry这五个字母>___<//
: 问:要怎样将这里面的四个参数一次放进去呢?
: 请问大家~感谢!
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.134.117.191
1F:推 robinnpca:完全成功!很感谢拉! 09/22 21:01