Reputation: 445
I am doing an images gallery in JavaScript and I have a problem adding properties to my img
object.
Here is my code:
img_big.src = photos[i].img_src;
img_big.className = "highslide";
img_big.onclick = "return hs.expand(this)";
My problem is in the last line. How can I add properties to objects in a for
loop before pushing them into an array?
The object should has these properties:
<a href="path" class="highslide" onclick="return hs.expand(this)">
<img src="path" alt="Highslide JS" title="Click to enlarge" /></a>
Upvotes: 0
Views: 161
Reputation: 305
Try this approach
img_big.src = photos[i].img_src;
img_big.className = "highslide";
img_big.onclick = function() { return hs.expand(this); }
Upvotes: 1