+ 4
Why console is displaying error ??
Help me in fixing this error plzz. https://code.sololearn.com/WwW3UmbtSVGk/?ref=app
8 Antworten
+ 2
I still can't see the background image. May be some problem with the link.
Anyways, it's giving you error bcz the js part is getting loaded before the html part gets so it can't find that id "i1" that's why it's None.
You need to put all your js code inside a function which will be called after the html window get loaded.
It can be done as:
window.onload = function(){
var images=["https://cdn.pixbay.com/photo/2016/10/21/08/39/halloween-1757492_960_720.jpg"];
var i1 = document.getElementById("i1");
var a =0;
window.onload=setInterval(function()
{i1.style.backgroundImage="url("+images[a]+")";
a +=1 ;
if (a==images.length-1)
{ }
},2000);
}
and now you don't need that inner window.onload.
+ 7
Shashi Ranjan Thx for the help!!! I made a typo in img url. Now, I have fixed that.
+ 6
No. I am working on looping just once. I will add more bg images and they will swipe after one another just for once. I was trying with one image at first only.
+ 2
console is going nuts and bolts
+ 2
tried running just the image url on the internet and it could not and would not answer call
+ 2
ok as long as we are on the same page just as using a carousel with one image then filling in ~ more images
+ 2
Arushi Singhania yea, now I can see some backgrounds changing.👍
+ 1
Did you mean for it to connect / flash and disappear