Latest news
Home » PHP » jquery smooth scrolling of internal anchor links

jquery smooth scrolling of internal anchor links

jquery smooth scrolling of internal anchor links

<script>
jQuery(document).ready(function(){
jQuery(‘a[href^=”#”]’).on(‘click’,function (s) {
s.preventDefault();
var smarttarget = this.hash,
$smarttarget = jQuery(smarttarget);
jQuery(‘html, body’).stop().animate({
‘scrollTop’: $target.offset().top
}, 900, ‘swing’, function () {
window.location.hash = smarttarget;
});
});
});
</script>

<ul>
<li><h1>Contents</h1></li>

<li> 1.&nbsp; <a class=”msection” style=”color:#1155CC” href=”#section_1″>Tes1</a></li>

<li> 2.&nbsp; <a class=”msection” style=”color:#1155CC” href=”#section_2″>Test 2</a></li>
</ul>

<a id=”section_1″ name=”section_1″></a>
<h1>1.Test1</h1>
<p>Test content </p>

Leave a Reply

x

Check Also

website development

How to disable AdBlock extensions for a particular website

Example website is smarttips.in ,replace with your website and guide your users to disable the ...