0
Good afternoon,
I have a problem in my JS menu where there is a dropdown menu:
<!-- MENU USER -->
<div class="collapse navbar-collapse navbar-user" id="navbarSupportedContent">
<ul class="navbar-nav ml-auto">
<li class="nav-item dropdown">
<a class="nav-link dropdown" rule="button" data-toggle="dropdown" aria-haspopup="true" href="#" id="navbarDropdownMenuLink">
<?php
echo "<span class=\"userlogin\">".get_info_session($APP_IN_CODIGO, 'USU_ST_NOME')."</span>";
?>
<i class="fa fa-angle-down icon-rotates"></i>
</a>
<!-- MENU DROPDOWN LOGOUT USER -->
<div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
<a href="?close_session" class="dropdown-item">Logout</a>
</div>
<!-- FIM MENU DROPDOWN -->
</li>
</ul>
</div>
My problem is when I ask to hide the dropdown but the menu does not make the arrow Rotate 180 down again, the arrow continues facing up.
Below is my JS code:
<!-- JS PARA EFETUAR O GIRO DO FONTAWESOME ANGLE-DOWN -->
<script type="text/javascript">
$('.nav-link').click(function(){
if ($(this).css("transform") == 'none') {
$(".dropdown").on("hidden.bs.dropdown", function(){
$(this).find('.nav-link').children().css('transform', 'none');
});
$(this).children().css('transform', 'rotate(180deg)');
} else {
$(this).children().css('transform', 'none');
}
});
</script>
CSS:
/* EFETUAR O GIRO DO FONTAWESOME ANGLE-DOWN */
.icon-rotates {
transition: 0.5s;
}
.icon-rotates.rotate {
transform: rotate(180deg);
}
/********************************************/
Could someone help me tell what I’m doing wrong so the little arrow just turns up and doesn’t come back down?
Kosonome Good morning, the arrow came back, but I have another problem. When clicking on another MENU option, the arrow of the other MENU option went up and the one that was up went down. How can I do this with this suggestion of yours? Sorry for JS ignorance, I don’t know much about the language. Thank you.
– Leandro Ferreira
If you edit your question with more code from this other menu where the problem is happening, I can help you.
– Kosonome
Good morning Kosonome, I was able to solve my problem by inserting the part of the code "Hidden.bs.dropdown" into if($(this).css("Transform") == 'None') .
– Leandro Ferreira