2015-10-18 131 views
1

我會跳到<fieldset>與類"secound",但跳轉不起作用。 我的代碼有什麼問題? 對不起,我的英語,我希望你能幫助我?

$(".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(); 
 
}
<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>

+0

你缺少了)在next_fs.show(); }你寫的next_fs.show(); }) – Bak

+0

這是代碼,我不會跳轉到下一個字段集。我將跳轉到一個類的自定義字段集。 http://thecodeplayer.com/walkthrough/jquery-multi-step-form-with-progress-bar – mirko

回答

0

的.secound字段集是不是你點擊元素的父。

1

如果你想比較你

textnext 

單擊該按鈕的價值,你需要做的

if(textnext == $(this).val()){ 
    next_fs = $(this).parent(".secound").next(); 
} 
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>