javascript - How to slide a banner using jquery?
980
code:
<script>
var slideIndex = 1;
showSlides(slideIndex);
function plusSlides(n) {
showSlides(slideIndex += n);
}
function currentSlide(n) {
showSlides(slideIndex = n);
}
function showSlides(n) {
var i;
var slides = document.getElementsByClassName("mySlides");
var dots = document.getElementsByClassName("dot");
if (n > slides.length) {slideIndex = 1}
if (n < 1) {slideIndex = slides.length}
for (i = 0; i < slides.length; i++) {
slides[i].style.display = "none";
}
for (i = 0; i < dots.length; i++) {
dots[i].className = dots[i].className.replace(" active", "");
}
slides[slideIndex-1].style.display = "block";
dots[slideIndex-1].className += " active";
}
</script>
<div >
<?php
if(empty($banner))
{
echo $this->session->flashdata('error');
}
else
{
foreach($banner as $ban)
{
?>
<a href="<?php echo base_url(); ?>product/<?php echo $ban['category']; ?>">
<div >
<img src="<?php echo base_url(); ?>asset/banner/<?php echo $ban['banner']; ?>" >
</div>
</a>
<?php
}
}
?>
<a onclick="plusSlides(-1)">❮</a>
<a onclick="plusSlides(1)">❯</a>
</div>
In this code I am creating banner slider section where images are showing dynamically perfect but images are not sliding automatically one by one. So, How can I slide images one by one? Please help me.
Thank You
Answer
Solution:
I don't see any element with class dot. Removing references to those you can simply add a setInterval() callback.
Answer
Solution:
itv = setInterval(callback, timing)
to autoplay the slideshowclearInterval(itv)
on'mouseenter'
Event.onclick=""
Here's a slightly modified example:
People are also looking for solutions of the problem: trying to access array offset on value of type null
Source
Share
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Answer
Solution:
itv = setInterval(callback, timing)
to autoplay the slideshowclearInterval(itv)
on'mouseenter'
Event.onclick=""
Here's a slightly modified example:
People are also looking for solutions of the problem: trying to access array offset on value of type null
Source
Share
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.