I am looking for an alternative method to achieve a similar effect to .toggleClass()
, that will toggle a specific class to an element on/off, (since .toggleClass()
does not appear to be compatible with Safari.)
This is the line of code that I am using to implement the class I am wanting to toggle between:
$window.on('scroll', function() {
div2.toggleClass('show', scrollTop >= (div1_top - window_top_to_div2) && (scrollTop + window.innerHeight) <= (div1_bottom + window_top_to_div2));
});
Additionally, I have provided a more extensive snippet of this in my previous post, here: Can toggleClass Work in Safari? (JQuery)