i would like to check for the window size with jquery and based on the different resolutions i would like to change the background image. So i was thinking to somehow use the “switch” statement for more cases, but i just don’t know how this would look like. This is the basic structure i want but with more options:
if ((screen.width>=1024) && (screen.height>=768)) {
//do something
}
else {
//do something else
}
Thanks for your help.
The
switchstatement won’t let you do stuff like checking for numbers between certain values, and it won’t let you check on multiple variables, either…So for this particular scenario, I think the best fit is actually just a list of
if-elseifstatements, like you’re already on your way to do.To do “range checks” in
switchis really verbose: