Jquery $(this).parent()。next();

时间:2015-10-18 19:09:18

标签: jquery html

我会使用课程<fieldset>跳转到"secound",但跳转不起作用。 我的代码有什么问题? 抱歉我的英语,我希望你可以帮助我?

&#13;
&#13;
$(".next").click(function(){
    textnext = "next1";
    current_fs = $(this).parent();
    next_fs = $(this).parent().next();

    if( textnext == $(".next").val()){
        next_fs = $(this).parent(".secound").next();
    }
    next_fs.show();
}
&#13;
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>

<fieldset style="height:100vh">
    <input type="button" name="next" class="next action-button" value="next1" />
</fieldset>
<fieldset style="height:100vh" class="first">
    <input type="button" name="next" class="next action-button" value="Next" />
</fieldset>
<fieldset style="height:100vh" class="secound">
    <input type="button" name="next" class="next action-button" value="Next" />
</fieldset>
&#13;
&#13;
&#13;

4 个答案:

答案 0 :(得分:1)

如果要将您点击的按钮的值与

进行比较
textnext

,你需要做

if( textnext == $(this).val()){
    next_fs = $(this).parent(".secound").next();
}

答案 1 :(得分:0)

.secound字段集不是您点击的元素的父级。

答案 2 :(得分:0)

这就是你想要做的事情?

$(".next").click(function(){
   
    var textnext = "next1";
  
    var current_fs = $(this).parent();
  
    var next_fs = $(this).parent().nextAll('.secound');
  
   $('body').scrollTop( next_fs.offset().top);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<div id='test'>
  
<fieldset style="height:50vh">
    <input type="button" name="next" class="next action-button" value="next1" />
</fieldset>
<fieldset style="height:50vh" class="first">
    <input type="button" name="next" class="next action-button" value="Next" />
</fieldset>
<fieldset style="height:50vh" class="secound"  >
    <input type="button" name="next" class="next action-button" value="Next" />
</fieldset>
</div>

答案 3 :(得分:0)

这是代码,我不会跳转到下一个字段集。我将跳转到一个类的自定义字段集。 http://thecodeplayer.com/walkthrough/jquery-multi-step-form-with-progress-bar