The brute force way to do it.
On Call (wizard element id/class, no. of steps): resetJQuerySteps('#wizaro',3);
Requirements:
jquery.steps.css
jquery-3.1.1.min.js
jquery.steps.min.js
Notes:
Add a click event listener for the reset button on page load to set the reset button function, in case the id of the reset button is "resetJSteps" then its query form is "#resetJSteps" also append ".click" or any function that will trigger the reset function, just see the javascript code or search for the vanilla javascript of the click event listener and DOM page load.
The parameters of the resetJQuerySteps should be the id of the div wizard which is the "wizaro" then its query form is "#wizaro" and the number of steps, in this case, it's only "3" steps which are the "key, effects, pager"
Available also in CodePen:
//to load the wizard form
$(".wizard").steps({
headerTag: "h3",
bodyTag: "section",
transitionEffect: "fade",
autoFocus: true
});
/* Can be replaced with vanilla js code!
When the user click the reset button, the steps will be reset */
$(document).ready(function(){
$("#resetJSteps").click(function(){
resetJQuerySteps('#wizaro',4);
});
});
/* Add this snippet below in your javascript code, this is the
function that will reset the wizard form */
function resetJQuerySteps(elementTarget, noOfSteps){
var noOfSteps = noOfSteps - 1;
var currentIndex = $(elementTarget).steps("getCurrentIndex");
if(currentIndex >= 1){
for(var x = 0; x < currentIndex;x++){
$(elementTarget).steps("previous");
}
}
setTimeout(function resetHeaderCall(){
var y, steps;
for(y = 0, steps= 2; y < noOfSteps;y++){
//console.log(steps);
try{
$(`${elementTarget} > .steps > ul > li:nth-child(${steps})`).removeClass("done");
$(`${elementTarget} > .steps > ul > li:nth-child(${steps})`).removeClass("current");
$(`${elementTarget} > .steps > ul > li:nth-child(${steps})`).addClass("disabled");
}
catch(err){}
steps++;
}
}, 50);
}
/* PLAIN CSS */
body {
font-family: system-ui;
background: white;
color: black;
}
#wizaro{
margin-top:10px;
}
<!-- CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<link href="https://jerwinkdc.github.io/html-codes/css/steps/jquery.steps.css" rel="stylesheet">
<div id="wizaro" class="wizard">
<h3>Keyboard</h3>
<section>
<p>Try the keyboard navigation by clicking arrow left or right!</p>
</section>
<h3>Effects</h3>
<section>
<p>Wonderful transition effects.</p>
</section>
<h3>Pager</h3>
<section>
<p>The next and previous buttons help you to navigate through your content.</p>
</section>
<h3>Finalize</h3>
<section>
<p>The last content.</p>
</section>
</div>
<button id="resetJSteps" style="margin-left:15px;" class="btn btn-primary" type="button">
Reset!
</button>
<!-- SCRIPTS -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://jerwinkdc.github.io/html-codes/js/steps/jquery.steps.min.js"></script>
<script src="https://jerwinkdc.github.io/html-codes/js/validate/jquery.validate.min.js"></script>