我需要隐藏当前的 div 并显示下一个 hide 这是我的代码
$(document).ready(function() {
$('#next').click(function() {
$(this).next().next().children("div").hide();
$(this).next().next().children("div").show();
});
});
#div2,
#div3 {
display: none;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.0/jquery.min.js"></script>
<button id="prev">Prev</button>
<button id="next">Next</button>
<hr />
<div id="main">
<div id="div1">Div 1</div>
<div id="div2">Div 2</div>
<div id="div3">Div 3</div>
</div>
最佳答案
看this .
使用 css
类处理开始/结束,保持 js
简单。
关于javascript - jQuery : how to show the next div and hide the present one,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9978491/