This is the code I have for opening a dropdown menu $smallScreenMenu when $iconMenu1 is clicked
Javascript code:
const $iconMenu1 = $('#iconMenu1')
const $smallScreenMenu = $('#smallScreenMenu')
$($iconMenu1.on('click', ()=>{
if ($smallScreenMenu.css('display') == 'block'){
$smallScreenMenu.css('display', 'none');
}
else{
$smallScreenMenu.css('display', 'block');
}
CSS code:
.icon-menu{
right: 15px;
position: absolute;
top: 17px;
font-size: 30px;
background-color: transparent;
border: none;
}
#smallScreenMenu{
display: none;
position: absolute;
right: 0px;
text-align: right;
HTML code:
<button class='icon-menu' id='iconMenu1'></button>
<div id='smallScreenMenu'>
<ul>
<li><a href='#'>Products</a></li>
<li><a href='#'>About</a></li>
</ul>
</div>
It works but I want it to slide instead of instantly appear/disappear. Can I modify this code to achieve that, or do I need to start from scratch? I tried using slideDown() and slideUp() without success. Thank you in advance for your help