I have a bird={} object, and I want the bird object to have an image to represent it, but I need to have other properties inside the bird other than its image. How do I do that? Thanks in advance.
Asked
Active
Viewed 103 times
0
-
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object – Teemu Feb 15 '17 at 10:27
-
did you try something ? – ᴄʀᴏᴢᴇᴛ Feb 15 '17 at 10:41
-
I got there now, thanks. – Mighty Salmon Studios Limited Feb 15 '17 at 10:46
3 Answers
0
You can simply use the following code to create a HTML DOM Image Object.
var bird = new Image();
bird.src = "http://www.ImageURL.png";

user7393973
- 2,270
- 1
- 20
- 58
-
-
@MightySalmonStudiosLimited, please make a new question with your issue so I can check it and try to help. That way you will get more attention from others too and at the same time, avoid editing and commenting to much here. (reply to your deleted comment) – user7393973 Feb 15 '17 at 15:18
-
It does not let me as this question was marked down by someone. would you mind answering if I send you an email or something? – Mighty Salmon Studios Limited Feb 15 '17 at 15:30
-
@MightySalmonStudiosLimited, I upvoted to match (0). Does that help? – user7393973 Feb 15 '17 at 15:33
0
Try something like this:
var bird = {color: "blue", weight: 30, eyeColor:"#0000ff", imageSoure: "C:/Users/..../bird.png"};

Grigoris Dimopoulos
- 124
- 6