jquery - Execution order of if else issue -
i have function, part of works non-correct.
what need -
1) if window width < 768 (do smth)
2) if window width = 768 (do smth)
3) else (do smth)
there part of function
var windowwid = $(window).width(); if ($poselok.length > 0) { if (windowwid === 768) { var offset = 0.05; } if (windowwid < 768) { var offset = 0 - $el_full.offset().left - el_margin_left; } else { var offset = 0 - $el_full.offset().left + $sideleft + 15; } } else { var offset = 0 - $el_full.offset().left - el_margin_left; };
without if (windowwid < 768)
condition if (windowwid === 768)
works, - doesn't.
i tried if (windowwid < 767)
, if (windowwid <= 767)
separate if
nothing.
i tried replace if
, (windowwid === 768)
works if (windowwid < 768)
works incorrect.
i think have mistake in execution order, don't know how fix it.
help please!
if (condition1) { block of code executed if condition1 true } else if (condition2) { block of code executed if condition1 false , condition2 true } else { block of code executed if condition1 false , condition2 false }
Comments
Post a Comment