I looked through many links to get an answer to my problem, but I could not find a solution that so decided to ask.
I am using the html canvas element to display the active slide. when you click the next button, the active border color of the canvas element should become normal, and the next color of the canvas element border should change to identify the active. But it does not work.
This is HTML
<div class="slider-nav">
<a href="#" class="arrow-prev"><img src="http://s3.amazonaws.com/codecademy-content/courses/ltp2/img/flipboard/arrow-prev.png" /></a>
<ul class="slider-dots">
<li><canvas class="dot active-dot" width="50" height="10"></canvas></li>
<li><canvas class="dot" width="50" height="10"></canvas></li>
<li><canvas class="dot" width="50" height="10"></canvas></li>
<li><canvas class="dot" width="50" height="10"></canvas></li>
</ul>
<a href="#" class="arrow-next"><img src="http://s3.amazonaws.com/codecademy-content/courses/ltp2/img/flipboard/arrow-next.png" /></a>
</div>
This is css
canvas {
border:2px solid deepskyblue;
border-radius: 50px;
}
canvas.active-dot {
border:2px solid green;
border-radius: 50px;
}
This is a script
var main = function() {
$('.arrow-next').click(function() {
var currentDot = $('.active-dot');
var nextDot = currentDot.next();
if(nextDot.length === 0) {
nextDot = $('.dot').first();
}
$('active-dot').removeClass('active-dot');
$(this).next().addClass('active-dot');
});
$('.arrow-prev').click(function() {
var currentDot = $('.active-dot');
var prevDot = currentDot.prev();
if(prevDot.length === 0) {
prevDot = $('.dot').last();
}
currentDot.removeClass('active-dot');
prevDot.addClass('active-dot');
});
};
$(document).ready(main);
source
share