有沒有什麼辦法讓這個代碼的工作! 我試圖顯示DIV(slidingDiv)並轉到選定的錨(#anchor-01 +#anchor-02 +#anchor-03)... 此代碼讓我只能進入DIV中的第一行。 那麼請你怎麼跳到確切的錨? 感謝
<html>
<head>
<title>Test show hide tab</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
$(".slidingDiv").hide();
$(".show_hide").show();
$('.show_hide').click(function(){
$(".slidingDiv").slideToggle();
});
});
</script>
<style type="text/css">
.slidingDiv {
background-color: #99CCFF;
padding:20px;
margin-top:10px;
border-bottom:5px solid #3399FF;
}
.show_hide {
display:none;
}
</style>
</head>
<body>
<a href="#anchor-01" class="show_hide">Show/hide 01</a> -- <a href="#anchor-02" class="show_hide">Show/hide 02 </a> -- <a href="#anchor-03" class="show_hide">Show/hide 03</a>
<hr>
<div class="slidingDiv">
<div id="anchor-01">
<h2>Tite for link anchor 01</h2>
Fill this space with really interesting content. <a href="#" class="show_hide">hide</a>
<br><br><br><br><br><br><br><br><br><br><br>
</div>
<div id="anchor-02">
<h2>Tite for link anchor 02</h2>
Fill this space with really interesting content. <a href="#" class="show_hide">hide</a>
<br><br><br><br><br><br><br><br><br><br><br>
</div>
<div id="anchor-03">
<h2>Tite for link anchor 03</h2>
Fill this space with really interesting content. <a href="#" class="show_hide">hide</a>
<br><br><br><br><br><br><br><br><br><br><br>
</div>
</div>
</body>
</html>
所以你說你想讓這三個內容隨時可見,只需要滾動父級?咦? –