I'm new to javascript thing and got the below slider javascript and html code from online.
<script>
var slideIndex = 1;
showSlides(slideIndex);
function blogcurrentSlide(n) {
showSlides(slideIndex = n);
}
function showSlides(n) {
var i;
var slides = document.getElementsByClassName("mySlides");
var dots = document.getElementsByClassName("blogdot");
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(" blogactive", "");
}
slides[slideIndex-1].style.display = "block";
dots[slideIndex-1].className += " blogactive";
}
</script>
<span class="blogdot" onclick="blogcurrentSlide(1)"></span>
<span class="blogdot" onclick="blogcurrentSlide(2)"></span>
<span class="blogdot" onclick="blogcurrentSlide(3)"></span>
<div class="mySlides fade">
<% @loadpostslandingfirst.each do |post| %>
</div>
<p id="blogtitle">
<b>
<%= truncate(post.blog_title, :length=>60) %>
</b>
</p>
Currently, it works on click only but I also want the swipe function on the smartphone.
I found a similar article but couldn't understand it at all.
Any help would be much appreciated.