Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
oopsjoe authored Apr 10, 2024
1 parent 419a3e6 commit bc10c20
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions _javacript/menu.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
$(document).ready(function() {
// 设置滑动条的初始位置为首页
var $homeLink = $("#nav li:nth-of-type(2) a"); // 注意这里选择的是第二个 li 元素,因为第一个是菜单按钮
var position = $homeLink.parent("li").position();
var width = $homeLink.parent("li").width();
$("#nav .slide1").css({ left: position.left, width: width });

// 点击事件处理
$("#nav li a").on("click", function () {
var position = $(this).parent().position();
Expand All @@ -17,9 +23,4 @@ $(document).ready(function() {
$("#nav li a").on("mouseout", function () {
$("#nav .slide2").css({ opacity: 0 }).removeClass("squeeze");
});

// 设置滑动条的初始位置
var currentWidth = $("#nav li:nth-of-type(2) a").parent("li").width();
var current = $("#nav li:nth-of-type(2) a").position();
$("#nav .slide1").css({ left: +current.left, width: currentWidth });
});

0 comments on commit bc10c20

Please sign in to comment.