在导航栏中单击“传奇”时,我试图进行开/关切换。但是,当我为addEventListener
构造函数时,我不断收到类型错误。我了解这是因为未定义info
,但是我不确定如何定义它,因此可以将style display
更改为block
,当{{1 }}在导航栏中单击。
有什么建议可以指出正确的方向吗?
HTML:
Legend
CSS:
<!--Navbar-->
<nav class="navbar">
<div class="logo">
<h4> Earthquake Feed</h4>
</div>
<ul class="nav-links">
<li><a href="#simpleModal" id="aboutModal">About</a></li>
<li><a href="#legend" id="legend">Legend</a></li>
</ul>
</nav>
Javascript:
/*CSS for legend*/
.info {
padding: 6px 8px;
font: 14px/16px Arial,Helvetica,sans-serif;
background: white;
background: rgba(255,255,0.8);
box-shadow: 0 0 15px rgba(0,0.2);
border-radius: 5px;
display: none;
}
.legend {
background-color: “black”;
line-height: 26px;
color: #555;
width: auto;