I'm trying to create a carousel using the basic example provided in w3schools.
On top of that I was creating an additional div
and inserting my content inside that. here is my Javascript.
<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>
Here is a working fiddle http://jsfiddle.net/h9sa7Lgw/
I've got 2 issues here,
- I want to bring the arrows inside my div(
mainDiv
). - The previous arrow(
<
) doesn't seem to work. In the fiddle even>
is not working, but in my local it does work.
My Question wasn't about the js fiddle, just was telling the problem with my fiddle, if the code is ran, it won't run.
Can someone please let me know where am I going wrong and how can I fix this.
Thanks