有没有什么办法让这个代码的工作! 我试图显示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>
所以你说你想让这三个内容随时可见,只需要滚动父级?咦? –