我想让我的每个" li"(st)标签在点击时重定向到一个页面。我不确定最好的方法是什么,但我有以下HTML导航设置:
<nav class="navigation_menu" id="navigation_menu">
<div class="menu-icon"></div>
<ul>
<li><span id = 'title' class = 'left title'>Cricket</span></li>
<li><a href = "index.php">Home</a></li>
<li><a href = "services.php">Services</a></li>
<li><a href = "prices.php">Prices</a></li>
<li><a href = "contact.php">Contact</a></li>
<li><a href = "suport.php">Support</a></li>
<li class = 'button'><button id = 'getstarted'>GET STARTED</button></li>
</ul>
</nav>
我对jQuery相当新,所以我对如何做到这一点并不是100%有信心。
答案 0 :(得分:0)
不要将Javascript用于您可以在CSS中轻松完成的任务:
li {
background: red;
}
a {
background: green;
display: block;
height: 100%;
width: 100%;
}
<nav class="navigation_menu" id="navigation_menu">
<div class="menu-icon"></div>
<ul>
<li><span id = 'title' class = 'left title'>Cricket</span></li>
<li><a href = "index.php">Home</a></li>
<li><a href = "services.php">Services</a></li>
<li><a href = "prices.php">Prices</a></li>
<li><a href = "contact.php">Contact</a></li>
<li><a href = "suport.php">Support</a></li>
<li class = 'button'><button id = 'getstarted'>GET STARTED</button></li>
</ul>
</nav>
background
规则仅用于说明a
元素现在与父li
的尺寸完全相同 - 您可以忽略它们代码。