簡體   English   中英

JS 在頁面各部分之間的轉換中不起作用

[英]JS does not work in transitions between parts of the page

我的網頁有問題https://www.martanking.eu/如果我向下滾動,導航消失並顯示箭頭以滑動導航。 但是,如果我在頁面的各個部分周圍使用 go,則此代碼不起作用。 無法單擊它。 我的代碼與許多 PHP 文件分開:(提示。您可以將我的頁面從捷克語翻譯成英語)。

請幫我。

我將給出一個JS代碼:

$(document).on('click', 'a[href^="#"]', function (event) {
    event.preventDefault();

    $('html, body').animate({
        scrollTop: $($.attr(this, 'href')).offset().top
    }, 800);
});



var nav = document.getElementById("bigNav");
var nav1 = document.getElementById("myDIV");
var nav2 = document.getElementById("myDIV2");
window.onscroll = function() {scrollFunction()};

function scrollFunction() {
  if (document.body.scrollTop > 280 || document.documentElement.scrollTop > 280) {
      nav.style.backgroundColor = "rgba(97, 99, 99, 0.8)";
      nav.style.width = "1%";
      nav.style.left = "0";
      nav.style.top = "0";
      nav1.style.opacity = "0";
      nav2.style.opacity = "0";
      nav.style.opacity = "0";
      document.getElementById("cs").style.visibility = "visible";
      document.getElementById("arrleft").style.visibility = "visible";
      testWi();
  } else {
    nav.style.width = "80%";
    nav.style.lineHeight = "5vw";
    nav.style.left = "10%";
    nav.style.backgroundColor = "transparent";
    nav.style.opacity = "1"
    nav1.style.opacity = "1";
    nav2.style.opacity = "1";
    document.getElementById("cs").style.visibility = "hidden";
    document.getElementById("arrleft").style.visibility = "hidden";
  }
}

var width = (window.innerWidth > 0) ? window.innerWidth : screen.width;




function newElem() {
  var newElem = document.createElement("A");
  newElem.innerHTML = "<i class='fas fa-arrow-alt-circle-right' id='arrleft'></i>";
  newElem.style.fontSize = "15vw";
  newElem.style.color = "white";
  newElem.style.position = "fixed";
  newElem.style.top = "5vw";
  newElem.style.left = "5vw";
  newElem.style.backgroundColor = "gray";
  function hoverNav() {
    nav.style.cursor = "pointer";
    document.getElementById("arrleft").style.transform = "scale(1.2)"; 
    }
}

function loadNav() {
    document.getElementById("arrleft").remove();
    nav.style.width = "96%";
    nav.style.left = "2%";
    nav1.style.width = "70%";
    nav1.style.width = "30%";
    nav1.style.top = "2vw";
    nav2.style.top = "2vw";
    nav1.style.zIndex = "1000";
    nav2.style.zIndex = "1000";
      function hoverNav() {
    nav.style.cursor = "pointer";
    document.getElementById("arrleft").style.transform = "scale(1.2)";
}
}

function hoverNav() {
    nav.style.cursor = "pointer";
    document.getElementById("arrleft").style.transform = "scale(1.2)";
}
function outNav() {
    document.getElementById("arrleft").style.transform = "scale(1)";
    nav.style.cursor = "pointer";
}

function show() {
    document.getElementById("cs").style.visibility = "hidden";
    document.getElementById("arrleft").style.visibility = "hidden";
    nav.style.width = "80%";
    nav.style.lineHeight = "5vw";
    nav.style.left = "10%";
    nav.style.backgroundColor = "rgba(97, 99, 99, 0.8)";
    nav.style.opacity = "1"
    nav1.style.opacity = "1";
    nav2.style.opacity = "1";
}


這是因為帶有class 'div3'DIV's位於帶有show() function 和id="cs"的按鈕前面。

添加此 CSS:

#cs {
   z-index: 100;
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM