我對手風琴的內容持有人的以下代碼工作正常。我似乎不能鍛鍊如何將頁面自動滾動到點擊部分的頂部。現在容器打開,但頁面根本不滾動。自動滾動手風琴到點擊部分的頂部
請幫忙! 摹
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name = "viewport" content = "user-scalable = no">
<title>TEST</title>
<link href="style/english.css" rel="stylesheet" type="text/css" />
<link href="style/reset.css" rel="stylesheet" type="text/css" />
<link href="style/jquery.ui.all.css" rel="stylesheet" type="text/css" />
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico">
<script type="text/javascript" src="scripts/jquery1.8.2.min.js"></script>
<script type="text/javascript" src="scripts/jquery-ui-1.10.3.custom.js"></script>
<!--Accordian menu JQuery-->
<script type="text/javascript">
$(function() {
$("#accordion").accordion({
active: 'none',
heightStyle: "content",
collapsible: true,
/*heightStyle: "fill"*/
});
});
</script>
<script>
function Clicked1(){
$("#accordion").accordion({ active: 0 });
}
function Clicked2(){
$("#accordion").accordion({ active: 1 });
}
function Clicked3(){
$("#accordion").accordion({ active: 2 });
}
function Clicked4(){
$("#accordion").accordion({ active: 3 });
}
function Clicked5(){
$("#accordion").accordion({ active: 4 });
}
function Clicked6(){
$("#accordion").accordion({ active: 5 });
}
</script>
<!--Accordian menu JQuery-->
</head>
<body>
<div id="mainContainer" style="background-color:#009edb;">
<!--Header-->
<div id="headerContainer">
<a href="index.html"><img src="images/header.jpg" width="1000" height="110" border="0" /></a>
<!--Menu-->
NAVIGATION CODE
<!--Menu-->
</div>
<!--Header-->
<!--Body-->
<div id="mainBodyContainerWhite">
<div id="topExtra"></div>
<!--Spotlight-->
<div id="spotlightBoxContainer">
<div id="spotlightBoxFull" style="height:440px;"><img src="images/case_spotlight.jpg" width="986" height="508" usemap="#Map2" border="0" />
<map name="Map2" id="Map2">
<area shape="rect" coords="1,1,247,169" href="#section1" onclick="Clicked1()" id="scroll" />
<area shape="rect" coords="494,2,740,169" href="#section1" onclick="Clicked2()" id="scroll" />
<area shape="rect" coords="248,170,492,338" href="#section1" onclick="Clicked3()" id="scroll" />
<area shape="rect" coords="741,171,983,335" href="#section1" onclick="Clicked4()" id="scroll" />
<area shape="rect" coords="3,338,247,506" href="#section1" onclick="Clicked5()" id="scroll" />
<area shape="rect" coords="491,338,739,507" href="#section1" onclick="Clicked6()" id="scroll" />
</map>
</div>
</div>
<!--Spotlight-->
<div id="accordion">
<!--Split-->
<h3 style="border-top:solid 1px #009edb; border-bottom:solid 1px #009edb;">ACCORDIAN 1</span></h3>
<div class="accordion-content">
<div id="ContainerLeftInner">
<div class="textInner">
TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST.
</div>
</div>
</div>
<!--Split-->
<h3 style="border-top:solid 1px #009edb; border-bottom:solid 1px #009edb;">ACCORDIAN 2</span></h3>
<div class="accordion-content">
<div id="ContainerLeftInner">
<div class="textInner">
TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST.
</div>
</div>
</div>
<!--Split-->
<h3 style="border-top:solid 1px #009edb; border-bottom:solid 1px #009edb;">ACCORDIAN 3</span></h3>
<div class="accordion-content">
<div id="ContainerLeftInner">
<div class="textInner">
TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST.
</div>
</div>
</div>
<!--Split-->
<h3 style="border-top:solid 1px #009edb; border-bottom:solid 1px #009edb;">ACCORDIAN 4</span></h3>
<div class="accordion-content">
<div id="ContainerLeftInner">
<div class="textInner">
TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST.
</div>
</div>
</div>
<!--Split-->
<h3 style="border-top:solid 1px #009edb; border-bottom:solid 1px #009edb;">ACCORDIAN 5</span></h3>
<div class="accordion-content">
<div id="ContainerLeftInner">
<div class="textInner">
TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST.
</div>
</div>
</div>
<!--Split-->
<h3 style="border-top:solid 1px #009edb; border-bottom:solid 1px #009edb;">ACCORDIAN 6</span></h3>
<div class="accordion-content">
<div id="ContainerLeftInner">
<div class="textInner">
TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST.
</div>
</div>
</div>
<!--Split-->
</div>
<!--Spotlight-->
</div>
</div>
<!--Body-->
<div id="footerContainer"></div>
</body>
</html>
非常感謝 - 欣賞它(幫助我學習更多),但那麼JS如何知道在某個特定區域點擊哪個手風琴部分?每個'點擊()'區域開闢了一個獨立的手風琴部分。 –
感謝@GeekyGaj的讚賞。我們正在使用'$(this).index()'。如果第一個區域被點擊,那麼'$(this).index()'值爲'0',因此活動手風琴將是第一個。接下來,如果第二個區域被點擊,那麼'$(this).index()'的值是'1',因此活躍的手風琴將是第二個,等等。 –
@palash,我使用了你的技術,但是在我之後已經刪除了所有onclick,點擊根本不起作用。 –