I have this loading bar. When you add active to div class="step", it adds progression. How do I add a next and previous button that makes active according to the step you are on.
Please help!
$(document).ready(function() {
$('.step').each(function(index, element) {
// element == this
$(element).not('.active').addClass('done');
$('.done').html('<i class="icon-ok"></i>');
if ($(this).is('.active')) {
return false;
}
});
});
@import url(https://fonts.googleapis.com/css?family=Open+Sans:300,400,700,600);
body {
background-color: #e6e6e6;
font-family: 'Open Sans', sans-serif;
}
#steps {
width: 505px;
margin: 50px auto;
}
.step {
width: 40px;
height: 40px;
background-color: white;
display: inline-block;
border: 4px solid;
border-color: transparent;
border-radius: 50%;
color: #cdd0da;
font-weight: 600;
text-align: center;
line-height: 35px;
}
.step:first-child {
line-height: 40px;
}
.step:nth-child(n+2) {
margin: 0 0 0 100px;
transform: translate(0, -4px);
}
.step:nth-child(n+2):before {
width: 75px;
height: 3px;
display: block;
background-color: white;
transform: translate(-95px, 21px);
content: '';
}
.step:after {
width: 150px;
display: block;
transform: translate(-55px, 3px);
color: #818698;
content: attr(data-desc);
font-weight: 400;
font-size: 13px;
}
.step:first-child:after {
transform: translate(-55px, -1px);
}
.step.active {
border-color: #73b5e8;
color: #73b5e8;
}
.step.active:before {
background: linear-gradient(to right, #58bb58 0%, #73b5e8 100%);
}
.step.active:after {
color: #73b5e8;
}
.step.done {
background-color: #58bb58;
border-color: #58bb58;
color: white;
}
.step.done:before {
background-color: #58bb58;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>CodePen - loadingbar</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css">
<link rel="stylesheet" href="./style.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>
</head>
<body>
<!-- partial:index.partial.html -->
<link href="//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css" rel="stylesheet">
<script src="https://kit.fontawesome.com/a076d05399.js"></script>
<div id="steps">
<div class="step active" data-desc="Listing information"><i class="far fa-hand-pointer"></i></div>
<div class="step" data-desc="Photos & Details"><i class="fas fa-mortar-pestle"></i></div>
<div class="step" data-desc="Review & Post"><i class="fas fa-shipping-fast"></i></div>
<div class="step" data-desc="Your order"><i class="fas fa-shopping-cart"></i></div>
</div>
<!--
Try adding the active class to another 'step'
to see what's going on :)
-->
<!-- partial -->
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script src="./script.js"></script>
</body>
</html>