Skip to content Skip to sidebar Skip to footer

Show Div On Click And Scroll To It

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'

Solution 1:

Please put the 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.
});

Solution 2:

$('#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);
});

Post a Comment for "Show Div On Click And Scroll To It"