+ 2
I want to create a text slider.But this code is throwing an error.Please help me with the JS portion.
8 Respostas
+ 3
Sololearn puts the script tag for the js in the head so when the showSlides() function runs it does so before HTML loads which results in undefined values when you try interacting with the DOM. To fix that use window.onload which will run code once the HTML loads:
window.onload = () => {
showSlides(slideIndex);
}
You can give window.onload a proper function if you want e.g. a function called start:
function start() {}
window.onload = start;
Extra: change the a tags into buttons
+ 2
look at this and see if it helps
https://code.sololearn.com/WGOl85408P8d/?ref=app
+ 1
TurtleShell Thanks bt its still not helping.Can you see to it?
+ 1
Aanisha Bhattacharyya not the whole thing just showSlides() function the way I showed you.
+ 1
TurtleShell its not helping still now
+ 1
Aanisha Bhattacharyya I know I'm late to the party but look at my code here and it may help
+ 1
Aanisha Bhattacharyya fixed it among other problems:
https://code.sololearn.com/WfdDM6ncTg45/?ref=app
0
TurtleShell there seems to be an issue with the carousel on both codes ~ review mine