嗨,这是我的代码的一部分。
我需要将数组中的每个图像链接到不同的URL。
这甚至可以从内部做到,比如
dataArrClothes.push(["imagename.jpg","<a href="someurl"></a> "Description"]);
非常感谢任何帮助。
var dataArrClothes = new Array();
dataArrClothes.push(["imagename.jpg", "Description"]);
dataArrClothes.push(["imagename.jpg", "Description"]);
答案 0 :(得分: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_src
和description
属性的对象数组。
答案 1 :(得分:0)
您可以使用对象文字,例如:
dataArrClothes.push(
{ImageUrl: 'imagename.jpg',
Description: 'Your description here'
});