我的rm(list=ls(pattern="^DC"))
rm(list=ls(pattern="^HX"))
rm(list=ls(pattern="^Time"))
rm(list=ls(pattern="^Code"))
功能无法正常工作。当我点击菜单栏移动菜单时,它就像闪光灯一样显示。它不稳定。当我单击菜单栏时,它会添加类但突然删除它们。点击事件有什么问题,我不明白。请告诉我如何管理这个。
这是我的代码:
onclick
.shown {
display: block !important;
}
.mobile-menu {
position: absolute;
z-index: 999;
height: 100vh;
width: 100%;
background: #e4e3e3;
top: 0;
left: 0;
line-height: 2;
display: none;
overflow: hidden;
z-index: 9999;
}
.mobile-menu .menu-list {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 70vh;
width: 100%;
}
.mobile-menu .menu-list .menu-item {
width: 100%;
text-align: center;
}
.mobile-menu .menu-list .menu-item .menu-link {
font-size: 22px !important;
text-decoration: none;
cursor: pointer;
font-weight: 700;
display: block;
transition: all .5s ease;
color: #00A139;
}
.mobile-menu .menu-list .menu-item .menu-link:hover {
color: #ffffff;
background: #00A139;
}
答案 0 :(得分:2)
鉴于您提供的代码,您将丢失:
下面是一个基本但功能性的工作示例:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<button type="button" name="button" onclick="changeBackground()">Change background</button>
<script type="text/javascript">
function changeBackground() {
document.body.style.background = "black";
}
</script>
</body>
</html>