So I have this code:
$(".left-nav-icon").on("click touchstart", function () {
$(".nav_aside").toggleClass("show");
});
It’s meant to display a sidebar when I click on a .left-nav-icon. It works perfectly on android but for some reason, just doesn’t work on ios. I’ve tried everything, this was the last code I tried and it still didn’t work.
I’ll appreciate any help, thanks.
2
Answers
Try writing your code like this instead. Updated code:
Unfortunately, I don’t have an iPhone and can’t test my answer, but I guess it works.
Before I try to present my solution, let me say one thing,
.on('click'
is usually used for live element. If your element is not live, it is better to use this.But my solution is:
1- make sure there is no element on
.left-nav-icon
. It may be, for example, a part of a div on the.left-nav-icon
element (in iphone). This way your click on the.left-nav-icon
will not be applied. this code can help you2- It is better to use raw JavaScript, this code is equivalent to your code: