i made a jsfiddle, https://jsfiddle.net/g7u0zkyc/1/.
I want the arrow up when i hover the subnav-content
(see code class).
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<div class="navbarSecond">
<div class='container'>
<div class="subnav">
<button class="subnavbtn">NEW RELEASES<i class='subnav-arrow down'></i></button>
<div class="subnav-content">
<div class='container'>
<div class='row'>
<div class='col-md-2 margin-right-subnav-links'>
<a href="#">test1</a>
<a href="#">test2</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
.navbarSecond {
overflow: hidden;
background-color: darkgrey;
}
.navbarSecond a {
float: left;
font-size: 14px;
color: white;
text-align: center;
padding: 10px 12px;
text-decoration: none;
}
.subnav {
float: left;
overflow: hidden;
}
.subnav .subnavbtn {
font-size: 14px;
border: none;
outline: none;
color: white;
padding: 10px 12px;
background-color: inherit;
font-family: inherit;
margin: 0;
}
.navbarSecond a:hover, .subnav:hover .subnavbtn {
background-color: black;
}
.subnav-content {
display: none;
position: absolute;
left: 0;
background-color: grey;
width: 100%;
z-index: 1;
}
.subnav-content a {
float: none;
width:200px;
color: white;
text-decoration: none;
padding:5px;
display: block;
text-align: center;
}
.subnav-content a:hover {
background-color: #eee;
color: black;
}
.subnav-content .normal-subnav-links a {
text-align: left;
}
.subnav-content .normal-subnav-links a:hover {
background:transparent;
}
.subnav:hover .subnav-content {
display: block;
}
.normal-subnav-links a:first-child {
font-weight: 700;
}
.margin-right-subnav-links {
margin-right:35px;
}
.subnav-arrow {
border: solid white;
border-width: 0 3px 3px 0;
display: inline-block;
padding: 3px;
margin-left:5px;
margin-right:0px;
transition: all 0.10s ease;
}
.down {
transform: rotate(45deg);
-webkit-transform: rotate(45deg);
}
.up {
transform: rotate(-135deg);
-webkit-transform: rotate(-135deg);
}
$('.subnavbtn').hover(function(){
$(this).children('i').toggleClass('down up');
});
您不需要JS,只需删除JS代码,然后添加以下CSS:
这也是您的摘录:
You can add below jquery to your code. Take a look at this JSFiddle. Is this expected behaviour?
EDIT: I've made some changes to your existing jquery code, so take a look at this JSFiddle too.