Hi kennyalmendral,
you can use this updated code that should work well for you.
function hdq_kennyalmendral()
{ ?>
<script>
setTimeout(function(){
hdq_create_prev_buttons();
jQuery(".hdq_quiz").on("click", ".hdq_prev_button", function(){
hdq_prev_click(this)
})
jQuery(".hdq_quiz").on("click", ".hdq_next_button", function(){
hdq_next_click(this)
})
}, 2000);
function hdq_create_prev_buttons(){
let data = '<div class="hdq_prev_button hdq_button" data-id = "'+HDQ.VARS.id+'" style = "margin-right: 1rem">BACK</div>';
let hdq_pagination_areas = document.getElementsByClassName("hdq_next_button");
for(let i = 1; i < hdq_pagination_areas.length; i++){
hdq_pagination_areas[i].insertAdjacentHTML("beforebegin", data);
}
let q = document.getElementsByClassName("hdq_finsh_button")[0];
data = '<div class="hdq_prev_button hdq_button hdq_hidden" data-id = "'+HDQ.VARS.id+'" style = "margin-right: 1rem">BACK</div>';
q.insertAdjacentHTML("beforebegin", data);
}
function hdq_next_click(){
if (HDQ.VARS.jPage === HDQ.EL.jPaginate.length) {
jQuery(".hdq_prev_button").removeClass("hdq_hidden");
}
}
function hdq_prev_click(el){
if (HDQ.VARS.jPage === HDQ.EL.jPaginate.length) {
jQuery(".hdq_finish .hdq_prev_button").addClass("hdq_hidden");
jQuery(".hdq_finish .hdq_finsh_button").addClass("hdq_hidden");
}
HDQ.VARS.jPage = parseInt(HDQ.VARS.jPage - 1);
jQuery(".hdq_question").hide();
jQuery(".hdq_jPaginate").hide();
let page = jQuery(".hdq_jPaginate");
let start = HDQ.VARS.jPage - 1;
let hdq_form_id = jQuery(el).attr("data-id");
if(start >= 0){
jQuery("#hdq_" + hdq_form_id + " .hdq_jPaginate:eq(" + parseInt(start) + ")")
.nextUntil("#hdq_" + hdq_form_id + " .hdq_jPaginate")
.show();
} else {
let start = jQuery("#hdq_" + hdq_form_id + " .hdq_question:first");
jQuery(start).show();
jQuery(start).nextUntil(".hdq_jPaginate:first").show();
console.log(jQuery("#hdq_" + hdq_form_id + " .hdq_jPaginate:first"))
}
jQuery(".hdq_results_wrapper").hide(); // in case the results are below the quiz
jQuery(".hdq_question:visible").next(".hdq_jPaginate").show();
}
</script>
<?php }
add_action("hdq_after", "hdq_kennyalmendral");