首先,給IDS你的元素:
<a id="next" href="">Next</a>
<table id="myTable">
<tr><td>text1</td></tr>
<tr><td>text2</td></tr>
<tr><td>text3</td></tr>
<tr><td>text4</td></tr>
</table>
<a id="prev" href="">Previous</a>
然後,隱藏除了第一個所有元素:
$("#myTable tr").hide().eq(0).show();
最後,請 「下一步」 和 「上一步」 按鈕切換相鄰兄弟的可見性,如果存在:
$("#next").click(function(e) {
e.preventDefault();
$("#myTable tr:visible").next().show().prev().hide(); // Will do nothing if the visible element is the last one
});
$("#prev").click(function(e) {
e.preventDefault();
$("#myTable tr:visible").prev().show().next().hide(); // Will do nothing if the visible element is the first one
});
什麼問題?你有什麼嘗試?你遇到了什麼麻煩? – 2012-01-31 22:02:55
你是什麼意思的「循環行」? – PeeHaa 2012-01-31 22:04:28