I have a problem here and I do not know how to solve, in theory, my function below 768px
was to add the class .navbar-inverse
to the tag nav
, and above 768px
is to remove it case exists, but nothing happens.
Edit: I've done some tests and I've seen that he is ALWAYS removing this class and therefore giving trouble.
My JS looks like this:
$(document).ready(function () {
$(window).resize(function () {
var $element = $("nav");
/*Abaixo de 768px, add a classe .navbar-inverse*/
if (window.innerWidth < 768) {
if(!$element.hasClass(".navbar-inverse")) {
$element.addClass(".navbar-inverse")
}
}
/* Acima de 768px, se existir a classe navbar-inverse ela é retirada*/
if (window.innerWidth > 768) {
if($element.hasClass(".navbar-inverse")) {
$element.removeClass(".navbar-inverse")
}
}
});
});
I can not see the problem, the nav
tag exists, but nothing happens.