首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Jquery $(this).parent().next();

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

Stack Overflow用户
提问于 2015-10-19 03:09:18
回答 4查看 1.8K关注 0票数 1

我将跳转到包含"secound"类的<fieldset>,但跳转不起作用。我的代码出了什么问题?对不起,我的英语,我希望你能帮助我?

代码语言:javascript
复制
$(".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();
}
代码语言:javascript
复制
<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>

EN

回答 4

Stack Overflow用户

发布于 2015-10-19 03:27:01

如果要比较单击的按钮的值

代码语言:javascript
复制
textnext

,你需要做的是

代码语言:javascript
复制
if( textnext == $(this).val()){
    next_fs = $(this).parent(".secound").next();
}
票数 1
EN

Stack Overflow用户

发布于 2015-10-19 03:23:12

.secound字段集不是您正在单击的元素的父级。

票数 0
EN

Stack Overflow用户

发布于 2015-10-19 04:46:20

这就是你想要做的?

代码语言:javascript
复制
$(".next").click(function(){
   
    var textnext = "next1";
  
    var current_fs = $(this).parent();
  
    var next_fs = $(this).parent().nextAll('.secound');
  
   $('body').scrollTop( next_fs.offset().top);
});
代码语言:javascript
复制
<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>

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33202058

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档