I have a javascript function to show/hide a div on click and I would like the page to scroll down to that div on show function. I have included the ScrollTop function but it doesn't seem to be working. Here is my code:
$('#output').hide();
$('#readMore').click(function(){
$('#output').show(150);
$('#readMore').hide(150);
return false;
$('html, body').scrollTop($('#output').offset().top);
});
$('#readLess').click(function(){
$('#output').hide(150);
$('#readMore').show(150);
});
return false;
at the end. $('#readMore').click(function(){
$('#output').show(150);
$('#readMore').hide(150);
$('html, body').scrollTop($('#output').offset().top);
return false; // Please put the return false; at the end.
});
$('#output').hide();
$('#readMore').click(function(){
$('#output').show(150);
$('#readMore').hide(150);
$('html, body').scrollTop($('#output').offset().top);
return false;//return need to be placed here
});
$('#readLess').click(function(){
$('#output').hide(150);
$('#readMore').show(150);
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.