I am trying to invoke the scrollTo
function directly from onclick
action.
Found many solutions but none of them not worked form me
I am trying to do this:
<button onclick="$(window).scrollTo('#mydiv',100);"type="button" placeholder="" />CLICK ME</button>
<div id="mydiv">
</div>
Try
<button onclick="$('html, body').animate({scrollTop: $('#mydiv').offset().top}, 2000);" type="button" placeholder="" />CLICK ME</button>
<div id="mydiv"></div>
Make sure you use jQuery 1.9.x