Jump to content

[Object Htmlimageelement] - Why Am I Getting This?


next

Recommended Posts

I place several images into an array, then call the elements to change the picture, but instead changing source to a URL, my array stores: [object HTMLImageElement]?

Why???

if (this.id == 'next') {
if (images.length > i+1) {
i++;
} else {
if (i != 0)
i--;
}
document.getElementById('gallery').src = images[i];

that's the code.

 

Also, why my conditionals aren't working as supposed to? For instance I thought that:

if (images.length > i)

would stop the image swap, but it doesn't, unless I change it to the awkward version above, In my current example array had 2 elements and "i" is set to 0. I click the link once "i" becomes 1, then I click it again, but the conditional doesn't stop it even though "i" becomes a 2 (and if I understand correctly 2 isn't greater than 2).

Edited by next
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.