日期:2011/11/23  来源:GBin1.com

jQuery的平滑页面内锚定插件提供给你一个轻量级的脚本帮助你添加页面内的锚定帮助你平滑的滚动页面。当然这里有其它的类似插件,不过这个是比较轻量级的版本。只有2kb,希望大家喜欢!

在线演示

jQuery代码

var JQUERY4U = {}
JQUERY4U.UTIL = {
/*
* Utility function used to make anchor links animate smoothly instead of jumping.
*/
smoothAnchor: function (anchorClass)
{
$('a.'+anchorClass).click(function () {
elementClick = $(this).attr("href")
destination = $(elementClick).offset().top;
$("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination}, 1100 );
return false;
})
}
}


 
<script type="text/javascript">
$(document).ready(function() {
JQUERY4U.UTIL.smoothAnchor('anchorLink');
});
</script>

使用方式

锚定链接

<!-- anchor link -->
<a href="#pagelink-1" class="anchorLink"><em>how much can I borrow?</em></a>

目标元素

<!-- target element -->
<div >

希望大家喜欢!

来源: jQuery的平滑页面内锚定链接插件:$.smoothAnchor()

相关文章:

  • 2022-12-23
  • 2022-01-05
  • 2022-12-23
  • 2021-09-14
  • 2022-01-27
  • 2021-07-28
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-09-14
  • 2022-12-23
  • 2022-01-24
  • 2022-12-23
  • 2022-02-08
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案