简体   繁体   中英

jquery next/prev button not working

I have created a jquery questionnaire, when the user clicks on the next and prev buttons it will navigate to the next question Click here i have noticed that my next and prev function does not next to the next question.

once the next button is click it mean't to go to the question and vise versa for the previous button. Below is a snippet of my code

if (parentContainer.next('.responsible-gaming__parentContainer').length) {
                parentContainer.hide();
                parentContainer.next('.responsible-gaming__parentContainer').show();
            }

Does anyone know how i can fix this issue

Looks like your selector was wrong..

try this:

http://jsfiddle.net/jFIT/y725p/7/

$('.nodetest__nextBtn').click(function () {
    $('.responsible-gaming__parentContainer:visible').hide().next('.responsible-gaming__parentContainer').show();
});
    $('.nodetest__prevBtn').click(function () {
    $('.responsible-gaming__parentContainer:visible').hide().prev('.responsible-gaming__parentContainer').show();
});

尝试使用jQuery的on()click函数

$( ".class" ).on( "click", function() { //do some stuff here; });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM