I just got done making a simple HTML/CSS website for one of our products and was pretty happy with myself, until one of my colleagues mentioned the menu doesn't work on iOS devices... Which is true!
It does not work on iPhone (6, 8 and X tested), nor on iPad, but works perfectly fine on desktop, Android and even Chrome Dev Tools emulating iOS devices.
I'm quite lost here as I already tried the following:
- Change the
href="javascript:void(0);
" tohref="#"
- Change the anchor tag to a button tag
- Change the anchor tag to a span tag with cursor: pointer;
- Put a pointer: cursor; in the anchor tag CSS
- I even tried scrapping the whole navbar for a Bootstrap one, with the issue still persisting
Now I know it has to be related to CSS or Javascript as the button DOES register the "click" since when I changed the href to #, it added that to the url of the page.
I took the code for the responsive menu on W3schools.
function hambClick() {
var x = document.getElementById("myMenu");
if (x.className === "menu") {
x.className += " responsive";
} else {
x.className = "menu";
}
}
I would be eternally grateful if someone could help me out with this. I made a codepen with most of the original code untouched here.
Thanks guys!