The value of obj.backgroundImage is url(/images/apple.jpg)
and the background-image style appears as url(“/images/apple.jpg”)
The background-image style should be url(/images/apple.jpg) not url(“/images/apple.jpg”). And when I tried changing the path to url(/imgs/apple.jpg), the background-image style appeared as url(“/imgs/apple.jpg”).
2 Likes
The property is background-image
, not backgroundImage
. You should do HTMLElement.style["background-image"] = 'url("/imgs/apple.jpg")';
.
I’ll try it. Thanks in advance
It doesn’t work. Image doesn’t appear, though the style appears on the element.
Hey @OmegaOrbitals2,
could you send the link to your repl?
It’s part of a programming language, you may find it pretty complicated 
I’ll take a look at it and see what I can do!
The link has been removed.
In which file is your error you need help with located?
Edit : Found it
You haven’t updated line 136 of magma/magma.js
. This is important because only styles applied to thestyle
property before the object is appended to the DOM will work. (Setting thestyle
attribute is different.)
Updated it, image still doesn’t show
Hmm, that’s odd, I’ll come back to this in a little bit and check it out on my PC (I’m on my phone right now so I don’t have access to proper dev console).
1 Like
Change line 14 for this :
apple.edit("backgroundImage", `url(/images/apple.jpg)`);
1 Like
Works perfectly for me! I asked ChatGPT to confirm if it was correct and then I realized it was correct since I used `` in other JS projects!
2 Likes
The backticks won’t change anything, the lack of words around the url might do it though.
Hmm, this is really strange. This is a tough one!
2 Likes
No, doesn’t work. Maybe it’s a replit bug?
2 Likes
Not possible, JS runs in your browser.
2 Likes
I doubt that, I’m not an expert on JS, but if you wait a little bit more, I’m sure more people will hop on the topic!
2 Likes
What do you expect to see as an output?
1 Like