对不起,如果这看起来很短/没有研究(我可能在错误的逻辑中考虑了所有错误的地方),但我觉得答案将是简单/直截了当。(Javascript/RaphaelJS)我将如何将变量追加到新数组中的新对象?
说我有一些变量设置,例如:
var path1 = paper.path("M 95, 259 L 110, 250... etc. etc.. ");
var path2 = paper.path("M 96 138 L 55, 100,... etc... etc..");
它们插入到一组...
var set1 = paper.set();
set1.push(icon1, path1);
编辑:这两个步骤X2 ^^^^^^^ ^^
然后,想要继续前进,并将新集合插入到具有自己ID的新对象的新数组中,所以我可以稍后在设置单击处理函数时引用该数组。
基本上我有什么办法可以将每个集合附加到这个新的对象数组中吗?
编辑:
这里有更具体是什么,我的工作。我创建了一个for循环通过阵列运行......这些作品,但它只能显示第一开关DIV无论哪一组被点击。相反,我想显示switch2当set2被点击...甚至switch3与set3 ..等。谢谢。
switches = [
{ id: 'switch1', set: set1 },
{ id: 'switch2', set: set2 }
],
current,
max,
i;
for (i = 0, max = switches.length; i < max; i++) {
initSwitch(switches[i].set, switches[i].id);
}
function initSwitch(switchStr, targetId) {
txElm = document.getElementById(targetId);
var clickHandler2 = (function (e) {
if (current) {
if (current === txElm) {
return;
}
current.style.display = '';
}
current = txElm;
current.style.display = 'block';
//this.toFront();
paper.safari();
});
set1.click(clickHandler2);
set2.click(clickHandler2);
最后编辑:
退房这个的jsfiddle我只是写了。我希望第一个框和图像显示“switch1”Div,后两个框显示“switch2”Divs。
http://jsfiddle.net/thecomplex/AEa2X/13/
是'segment1path'应该是'path1'? – Barmar