In reviewing the many questions and answers on this topic on StackOverflow, none of the solutions provided worked reliably. All CSS, JavaScript, jQuery and hybrid solutions had at least one deficiency that prevented the scroll from disabling and/or toggling effectively.
I've also searched the web high and wide and have not found a good answer.
So far I have this function:
function toggleScroll(btn, item) {
$(btn).click(function() {
$(item).toggleClass("noscroll");
});
}
...which will add a overflow: hidden;
to any class I want onclick
, and remove it on second click.
The thing is, this code doesn't work with iOS devices.
How could I make this work with iOS devices?
Ideally, I would prefer a pure CSS solution. But I understand that this may not be possible, especially the toggle component.
Any JavaScript or jQuery solution would be fine, as well.
Thanks in advance!