jquery next/prev按钮不工作

jquery next/prev button not working

本文关键字:工作 按钮 prev next jquery      更新时间:2023-09-26

我创建了一个jquery问卷,当用户单击下一个和上一个按钮时,它将导航到下一个问题单击此处,我注意到我的下一个或上一个函数不在下一个问题旁边。

一旦单击下一个按钮,就意味着不转到问题,反之亦然。下面是我的代码片段

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

有人知道我如何解决这个问题吗?

看起来您的选择器错误。。

试试这个:

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()点击函数

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