Reputation: 53
Hi this is the part of my code.
I need to link each image in the array to different urls.
Is this even possible to do it from inside, like
dataArrClothes.push(["imagename.jpg","<a href="someurl"></a> "Description"]);
Any help is greatly appreciated.
var dataArrClothes = new Array();
dataArrClothes.push(["imagename.jpg", "Description"]);
dataArrClothes.push(["imagename.jpg", "Description"]);
Upvotes: 0
Views: 152
Reputation: 91598
You can use an object literal, such as:
dataArrClothes.push(
{ImageUrl: 'imagename.jpg',
Description: 'Your description here'
});
Upvotes: 0
Reputation: 62392
You probably want to use an array of objects instead of an array of arrays..
var dataArrClothes = [];
dataArrClothes.push({ img_src: "imagename.jpg", description: "Description"});
dataArrClothes.push({ img_src: "imagename.jpg", description: "Description"});
This would give you the following...
dataArrClothes[0].img_src; // "imagename.jpg"
dataArrClothes[0].description: // "Description"
You then have array of objects with img_src
and description
properties.
Upvotes: 2