Hello,
I have a problem with ScrollTop, I would like scroll to a specific div:
Example:
This is the html code:
<div data-role="page" id="Page3" class="page MainPage ui-page ui-body-s ui-body-c ui-page-active" title="NRJ 12 Programmes" data-url="Page3" tabindex="0" style="min-height: 1279px;">
<section class="MainContent">
<div id="lstprog">
<div class="ProgramBlock" id="ProgramBlock1">...</div>
<div class="ProgramBlock" id="ProgramBlock2">...</div>
<div class="ProgramBlock" id="ProgramBlock3">...</div>
<div class="ProgramBlock" id="ProgramBlock4">...</div>
...
<div class="ProgramBlock" id="ProgramBlock60">...</div>
</div>
</section> <!-- Main Content -->
</div>
When I click on a specific button, I would like to scroll to the div "ProgrameBlock20"
$("#TimeSection1").click(function() {
$('#lstprog').animate({
scrollTop:$('#ProgramBlock20').offset().top},
'slow'); // doesn't work
var pos = $('#ProgramBlock19').position();
console.log(pos); // Works fine
})
But when I click on button (#TimeSection1), nothing happens
Do you know why?
Thanks