0
텍스트 레이블이 클릭 한 요소와 일치하는 요소의 색인 번호는 어떻게 결정합니까?요소로 스크롤
나는 목록을 가지고 :
LI들 중 하나가 내 화면을 클릭 한 후 페이지의 일치 된 DIV 중 하나를 아래로 스크롤 할 필요가있다<ul>
<li data-cont="item one">this is one</li>
<li data-cont="item 2">this is second</li>
<li data-cont="one more">this is another one</li>
</ul>
...
<div>item one</div>
<div>item 2</div>
<div>one more</div>
. 사업부의 인덱스를 얻기
는$('#li').click(function(){
var scrollNow = $(this).attr('data-cont');
$('html, body').animate({
scrollTop: $(
// here I need to scroll down to the item by index...
).offset().top
}, 500);
});
가능한 중복 http://stackoverflow.com/questions/6677035/jquery-scroll-을 할 필요가 요소 간) –