I am writing a simple function to toggle a menu for a mobile site but cannot get my code to work. I have looked at examples online and have followed them but I can't achieve to toggle the menu off.
<script type="text/javascript">
function toggleMen(id) {
var a = document.getElementById(id);
if(a.style.display='none'){
a.style.display='block';
}
else if (a.style.display='block'){
a.style.display="none";
}
}
</script>
As you can see I am trying to simply check what value display is at and set it accordingly. I know there may be more efficient ways but for now this is all I need.
Method Call:
toggleMen('menu');