0

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"]);
2
  • I'm sorry, I didn't understand what you want. Could you be more clear? Commented Feb 23, 2012 at 21:00
  • Can explain in more detail what you mean by "link an image to different urls"? Commented Feb 23, 2012 at 21:01

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

Comments

0

You can use an object literal, such as:

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.