2012-02-23 42 views
0

嗨,这是我的代码的一部分。 我需要将数组中的每个图像链接到不同的URL。 这是甚至有可能从内部做到这一点,如 dataArrClothes.push(["imagename.jpg","<a href="someurl"></a> "Description"]); 任何帮助,非常感谢。Javascript,如何将数组元素链接到不同的URL

var dataArrClothes = new Array(); 
dataArrClothes.push(["imagename.jpg", "Description"]); 
dataArrClothes.push(["imagename.jpg", "Description"]); 
+0

对不起,我不明白你想要什么。你能更清楚吗? – 2012-02-23 21:00:09

+0

可以更详细地解释“将图像链接到不同的URL”是什么意思? – 2012-02-23 21:01:10

回答

2

你可能想使用对象而不是数组的数组的数组..

var dataArrClothes = []; 

dataArrClothes.push({ img_src: "imagename.jpg", description: "Description"}); 

dataArrClothes.push({ img_src: "imagename.jpg", description: "Description"}); 

这会为您提供以下...

dataArrClothes[0].img_src; // "imagename.jpg" 

dataArrClothes[0].description: // "Description" 

然后你有具有img_srcdescription属性的对象数组。

0

您可以使用对象文本,如:

dataArrClothes.push(
    {ImageUrl: 'imagename.jpg', 
    Description: 'Your description here' 
    }); 
相关问题