我有一个页面,其中包含三个标签,每个标签都有标签。单击标签会打开每个选项卡(通过显示/隐藏 div)。每个选项卡都包含 MySQL 数据,每个选项卡底部的箭头指向下一个“页面”数据。
我的问题,当您单击箭头时,该页面确实会转到下一页数据,但是默认选项卡 (tab1) 是可见的,而其他两个选项卡是隐藏的,所以如果您在选项卡二上,请点击下一个箭头,您将被带回 tab1 并且必须点击 tab3 才能查看数据。
更改选项卡可见性的脚本在这里:
<script type="text/javascript">
$(document).ready(function () {
$("div.tab-headers>a").click(function () {
// Grab the href of the header
var _href = $(this).attr("href");
// Remove the first character (i.e. the "#")
_href = _href.substring(1);
// show this tab
tabify(_href);
});
tabify();
});
function tabify(_tab) {
// Hide all the tabs
$(".tab").hide();
// If valid show tab, otherwise show the first one
if (_tab) {
$(".tab a[name=" + _tab + "]").parent().show();
} else {
$(".tab").first().show();
}
}
// On page load...
$(document).ready(function () {
// Show our "default" tab.
// You may wish to grab the current hash value from the URL and display the appropriate one
tabify();
});
</script>
tab2的代码是:
<div class="tab">
<a name="tab2"></a>
<img src="images/glossary_shiptype.png" width="1643" height="952" />
<div class="glossary_body">
<table width="740" border="0">
<?php do { ?>
<tr>
<td><?php echo $row_ship_type['term']; ?>:</td>
<td><?php echo $row_ship_type['definition']; ?></td>
</tr>
<?php } while ($row_ship_type = mysql_fetch_assoc($ship_type)); ?>
</table>
</div>
<div class="glossary_arrow_back">
<?php if ($pageNum_ship_type > 0) { // Show if not first page ?>
<a href="<?php printf("%s?pageNum_ship_type=%d%s", $currentPage, max(0, $pageNum_ship_type - 1), $queryString_ship_type); ?>"><img src="images/arrow_left.png" /></a>
<?php } // Show if not first page ?>
</div>
<div class="glossary_arrow_forward">
<?php if ($pageNum_ship_type < $totalPages_ship_type) { // Show if not last page ?>
<a href="<?php printf("%s?pageNum_ship_type=%d%s", $currentPage, min($totalPages_ship_type, $pageNum_ship_type + 1), $queryString_ship_type); ?>"><img src="images/arrow_right.png" /></a>
<?php } // Show if not last page ?>
</div>
</div>