Just wondering what the best practice is for something like this; I have this function: which determines a few variable changes
states = function(){
if($('#Animation.switch.switchOff').length == 1){
animationtoggle = 0;
}
else{
animationtoggle = 1;
}
if($('#Autoscroll.switch.switchOff').length == 1){
scrolltoggle = 1;
}
else{
scrolltoggle = 0;
}
}
And i now have another JS file, where i need to check against those variables, do i just literally run the states() inside any other function? so that it re checks every time?
Local variables can be used for this purpose. Try something like this:
Then you can call the function
states()from any where and use that like below: