+ 1
why this image does not appear
i am making a slide image automatically or manually by clicking the next and previous button but the image does not appear only white color, please help me solve this problem and give me explanation why this problem can happen https://code.sololearn.com/W299dUpsstCV/?ref=app
10 Respostas
+ 1
Here is clean working code, using for of instead of loop. This way you only need to add urls to your array and it will keep working.
Also page will not render until it is ready, so now you can set what ever interval you want
https://code.sololearn.com/WCXE21oDq9pT/#html
+ 1
hmm strange
will post you new code
+ 1
Mike Choy ok my code is working well it turns me too fast set up time in its setInteval thanks for helping me and answer my question.
+ 1
Ah yes the issue is that the document has not been rendered on the first loop before you try to set the URL. This is an issue with Sololearn, you really need to wrap your code in a window.onload = function() {}
so that it only renders when the document is ready
+ 1
wow thank you Mike Choy
0
Hi hafizd21j
see below working code
var photosPack = ["https://image.ibb.co/jdHjtn/matteo_vistocco_424475.jpg","https://image.ibb.co/dRdPtn/tersius_van_rhyn_228779.jpg","https://image.ibb.co/mQC0Yn/nick_morrison_325805.jpg"];
var indexImg = 1;
var imgId=document.getElementByID("imgcontent");
function slideImg(){
if(indexImg == photosPack.lenght){
indexImg = 0;
}else{
imgId.setAttribute("src",photosPack[indexImg]);
indexImg++;
}
}
var setWaktu = setInterval(slideImg,200);
0
Mike Choy your code does not work even appear error
0
Wow
I learnt something too, I did not know you could just use the elements ID inside JS without doing a document.getElementByID, many thanks!
0
Mike Choy oh ok i also know that when i see tutorial how to make slide gallery images fron youtube i also think the same as you
0
How about this
https://code.sololearn.com/W1F10CX7kf20/?ref=app