JSFiddle - React, Tailwind, and code Playground
HTML
<button id="ctrl1" status="1" pass="1">1</button>
<button id="ctrl2" status="1" pass="1">2</button>
<button id="ctrl3" status="1" pass="1">3</button>
JavaScript
$.checker = function (steps, done){
(function bind(idx){
$(steps[idx]).on('click.checker', function (){
if( $.attr(this, 'status') == $.attr(this, 'pass' ) ){
$(this).off('.checker');
if( ++idx == steps.length ){
done();
} else {
bind(idx);
}
}
});
})(0);
};
$.checker('#ctrl1 #ctrl2 #ctrl3'.split(' '), function (){
alert('Упражнение выполнено верно');
});