summaryrefslogtreecommitdiff
path: root/assets/js
diff options
context:
space:
mode:
Diffstat (limited to 'assets/js')
-rw-r--r--assets/js/id-transition.js18
1 files changed, 18 insertions, 0 deletions
diff --git a/assets/js/id-transition.js b/assets/js/id-transition.js
new file mode 100644
index 0000000..9355b69
--- /dev/null
+++ b/assets/js/id-transition.js
@@ -0,0 +1,18 @@
+ $(function(){
+ //锚点跳转滑动效果
+ $('a[href*=#],area[href*=#]').click(function() {
+ console.log(this.pathname)
+ if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {
+ var $target = $(this.hash);
+ $target = $target.length && $target || $('[name=' + this.hash.slice(1) + ']');
+ if ($target.length) {
+ var targetOffset = $target.offset().top;
+ $('html,body').animate({
+ scrollTop: targetOffset
+ },
+ 1000);
+ return false;
+ }
+ }
+ });
+ })