I had a question about something weird. I have been using jquery window.with and window.resize but I don't feel like it is accurate, I have set it to do something at max-width 1200px, but it does it at 1280px? Is there something wrong with my code?
jQuery(window).resize(function() {
if (jQuery(window).width() <= 1200) {
if(!jQuery(".navbar-collapse .nav li").hasClass("fa fa-chevron-down")) {
document.querySelector('style').textContent += "@media screen and (max-width: 1200px) { " +
".fa, .fa-chevron-down:hover { color: black; }" +
".fa-chevron-down:before {content: normal;}" +
".nav .parent:before {display: inline-block;\n" +
" content: '\\f078';\n" +
" -webkit-border-after-width: 20px;\n" +
" top: 7px;\n" +
" position: absolute;\n" +
" right: 24px;\n" +
" font-size: 25px;\n" +
" z-index: 8;}" +
"" +
"}";
}
jQuery('.navbar-collapse .nav li').addClass("fa fa-chevron-down");
}
else if(jQuery(window).width() >= 1201) {
jQuery('.navbar-collapse .nav li').removeClass("fa fa-chevron-down");
}
});
Does anyone know how to fix this problem so it just adds the class at 1200px and removes it as 1201px?