I'm trying to change color to a header when it reaches a certain scroll. I use this script with jQuery:
var $document = jQuery(document),
$element = jQuery('#header'),
className = 'red';
$document.scroll(function() {
$element.toggleClass(className, $document.scrollTop() >= 400);
});
That works on every browser, except for IE8. Does IE8 does not support the toggleClass? How can I solve it?
Any help would be appreciated. Thanks
jsFiddle: http://jsfiddle.net/itzuki87/e4XTw/
in IE: http://jsfiddle.net/itzuki87/e4XTw/show/
.scrollTop()
than with.toggleClass()
.$
andjQuery
and what error do you get?$
andjQuery
. I only see that all jQuery result sets are prefixed with a$
which is not an uncommon practice to show directly in source that it is a jQuery result set.