简体   繁体   中英

JS does not work in transitions between parts of the page

I have problem my webpage https://www.martanking.eu/ If I scrolling down, the nav dissapear and shows arrow to slide the nav. But if I go around the sections of the page, this code not working. It is not possible to click on it. My code is separated to the many PHP files: (TIP. You can translate my page from Czech to English).

Please, help me.

I will give a JS code:

$(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";
}


This is because your DIV's with class 'div3' are in front of your button with show() function and id="cs" .

Add this CSS:

#cs {
   z-index: 100;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM