I am attempting to create a customized carousel using the basic example provided on w3schools.
In addition to that, I have created an extra div
and inserted my content inside it. Below is the JavaScript code I used:
<script>
var slideIndex = 1;
showDivs(slideIndex);
function plusDivs(n) {
showDivs(slideIndex += n);
}
function showDivs(n) {
var i;
var x = document.getElementsByTagName("table")
if (n > x.length) { slideIndex = 1 }
if (n < 1) { slideIndex = x.length }
for (i = 0; i < x.length; i++) {
x[i].style.display = "none";
}
x[slideIndex - 1].style.display = "block";
}
</script>
You can view a working example in this fiddle: http://jsfiddle.net/h9sa7Lgw/
I am facing two issues:
- I would like to place the navigation arrows inside my
mainDiv
. - The previous arrow (
<
) does not seem to work. In the fiddle, even the next arrow (>
) is not functioning, but it works locally.
This query relates to the functionality of my actual code rather than the fiddle. When running the code, it fails to execute. Can anyone point out where I might be making mistakes and suggest a solution?
Thank you.