javascript - why is this variable returning "undefined" -
i can't figure out why global variable ismob
returning undefined after trying set through if
statement.
i have been futting around bit , can seem find answer.
var ismob; var mobmenclicked = false; var scrnrefresh = false; $('.mobilemen').click(launchmenu); function scalesite() { scalevideo(); scalemenu(); } function scalemenu() { ismob=0; if($(window).width() < 1066) { ismob=0; } else { ismob=1; } //chrome .hide function fix $('.menubar').css('display', 'inline-block'); ismob=0; } alert(ismob);'
i thought declaring variable in proper spot. apparently not. can else see error? surely cannot. o.o
call scalesite()
in code call rest of function assignment happening.
$(document).ready(function() { var ismob; var mobmenclicked = false; var scrnrefresh = false; scalesite(); $('.mobilemen').click(launchmenu); }); function scalesite() { // scalevideo(); scalemenu(); } function scalemenu() { ismob=0; if($(window).width() < 1066) { ismob=0; } else { ismob=1; } //chrome .hide function fix $('.menubar').css('display', 'inline-block'); ismob=0; alert(ismob); }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
Comments
Post a Comment