I have a series of functions that i am passing the same variable to, however i want this variable’s value to change dependent on the window height. Setting var X works fine, though when i remove it and attempt to designate its value through a conditional statement it doesnt read:
<script>
var viewportHeight = $(window).height();
$(function() {
$(window).resize(function() {
if (viewportHeight >= 600) {
var X = 100;
}
if (viewportHeight < 600) {
var X = 50;
}
});
});
</script>
This of course would be placed within the same script tags as the scripts im affecting, as i dont believe its possible to set a global var this way.
change the x variable to global, try like this