I have done some coding inside Elementor to make a menu which opens with toggle bars and closes with Click Outside. But it also closes when i click a link and i do not want that. I am fine with Outside Click to close. Can Someone help
Here is the script that i am using
<script>
const toggle = document.getElementById('togglebtn');
const navbar = document.getElementById('sidebar');
document.onclick = function(e){
if(e.target.id !== 'togglebtn' && e.target.id !== 'sidebar'){
toggle.classList.remove('active');
navbar.classList.remove('active');
}
}
toggle.onclick = function(){
toggle.classList.toggle('active');
navbar.classList.toggle('active');
}
</script>
New contributor
Guri is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.