我在我的HTML中有一個垂直列表。該列表附近有一個頂部箭頭和底部箭頭。當我點擊頂部箭頭時,我希望這個列表逐步上升,而底部箭頭則相反。以下是我的html和Angular代碼。HTML列表步驟滾動到頂部和底部
<div class="verticalCarousel">
<a ng-click="scrolltoBottom();" class="scroll-to-bottom">BOTTOM</a>
<ul class="nav nav-tabs verticalCarouselGroup" role="tablist" id="messagestab" >
<li role="presentation">
TEST
</li>
<li role="presentation">
TEST
</li>
<li role="presentation">
TEST
</li>
<li role="presentation">
TEST
</li>
<li role="presentation">
TEST
</li>
<li role="presentation">
TEST
</li>
</ul>
<a ng-click="scrolltoTop();" class="scroll-to-top">TOP</a>
</div>
這裏是Angular的代碼。
var i = 1;
$scope.scrolltoBottom = function(){
var list = $(".verticalCarouselGroup");
var container = $(".verticalCarousel");
console.log(list.height()-list.offset().top+"= BOTTOM OF CARO")
console.log(container.height()-container.offset().top+"= BOTTOM OF container")
i = i+50;
list.css({
'position': 'relative',
'top':i ,
});
};
$scope.scrolltoTop = function(){
var list = $(".verticalCarouselGroup");
var container = $(".verticalCarousel");
console.log(list.height()-list.offset().top+"= BOTTOM OF CARO")
console.log(container.height()-container.offset().top+"= BOTTOM OF container")
i = i-50;
list.css({
'position': 'relative',
'top':i ,
});
};
我加了的jsfiddle
https://jsfiddle.net/arunkumarthekkoot/863z3kky/2/
你是什麼意思:名單上一步一步?你可以準備一個jsfiddle嗎? –
@Himanshu Tyagi請參閱https://jsfiddle.net/arunkumarthekkoot/863z3kky/2/ – user2827944
你想達到什麼目的? –