You can use the following to find the current page scroll position.
var scrollPosition = $(document).scrollTop();
That will return the current scroll position of the page.
Вопрос
i been implamenting a piece of code in my website that iv found trough phpacademy.org tutorials the tutorial is 'how to create a like button'. iv got the button to work o.k, but i need an extra bit on function. the problem is that when i click the like button the page pops back up to the top
function like_add(id){
$.post('like_add.php', {id:id}, function(data){
if(data == 'success'){
like_get(id);
} else {
alert(data);
}
});
function like_get(id){
$.post('like_get.php', {id:id}, function(data){
$('#article_'+id+'_likes').text(data);
});
function delete_like(id){
$.post('delete_like.php', {id:id}, function(data){
if(data == 'success'){
like_get(id);
} else {
alert(data);
}
});
}
is there anything i can apply to this script to save the scroll position???...i have applied save scroll position to links on my website but i cant figure out this:(
cheers
Решение
You can use the following to find the current page scroll position.
var scrollPosition = $(document).scrollTop();
That will return the current scroll position of the page.