Re: [問題] setAttribute一串參數
※ 引述《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
推
09/22 21:01, , 1F
09/22 21:01, 1F
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 3 之 3 篇):