The initial value of ww
is '100%'
, which is a string.
On $(document).ready
you call the adjustMenu()
method, which reads the value of ww
.
Both conditions (ww < 768
and ww >= 768
) evaluate to false, so adjustMenu()
does nothing on DOMready.
You can avoid this to call $(window).trigger('resize')
instead of calling adjustMenu()
in your $(document).ready(function() { ... }
method so that ww
has a numeric value:
$(document).ready(function() {
$(".nav li a").each(function() {
if ($(this).next().length > 0) {
$(this).addClass("parent");
};
})
$(".toggleMenu").click(function(e) {
e.preventDefault();
$(this).toggleClass("active");
$(".nav").toggle();
});
$(window).bind('resize orientationchange', function() {
ww = document.body.clientWidth;
adjustMenu();
});
$(window).trigger('resize');
});