我有一个按钮的下拉菜单:悬停但是当我点击子链接时,它就好像我点击了父母的按钮(悬停设置的按钮)。
HTML:
<button id="Portfoliobut" class="dropbtn" onclick="window.location.href='index.html#Portfolio'" data-toggle="dropdown">Portfolio<div class="dropdown-content">
<a id="dropitlow" class="weblink1" >Web / UI</a>
<a id="dropitlow" class="designlink1">Design</a>
<a id="dropitlow" class="marketinglink1">Marketing</a>
<a id="dropitlow" class="otherlink1">Other</a>
</div></button>
Jquery的:
<script>
$("#homebut").click(
function(){ window.location = "index.html" }
);
$(".weblink1").click(
function(){ window.location = "web.html" }
);
$(".designlink1").click(
function(){ window.location = "design.html" }
);
$(".marketinglink1").click(
function(){ window.location = "marketing.html" }
);
$(".otherlink1").click(
function(){ window.location = "other.html" }
);
CSS:
#dropitlow{
z-index: 10;
height: 8px;
background-color: burlywood;
}
#dropitlow:hover{
background-color: honeydew;
z-index: 10;
}
#Portfoliobut{
width: 33.3%;
height: 100%;
background-color: aliceblue;
float: left;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
font-size: 10pt;
width: 100%;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 8
}
.dropbtn {
display: inline-block;
text-align: center;
text-decoration: none;
}
我不确定如何使锚点将窗口位置更改为我在jquery中设置的位置。我点击子菜单项,父母(按钮)高亮显示整个菜单是可点击按钮的一部分。我想保留一个按钮,因为它与其他菜单按钮一起设置。