[英]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.