Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6528713
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T09:33:36+00:00 2026-05-25T09:33:36+00:00

i would like to check for the window size with jquery and based on

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T09:33:37+00:00Added an answer on May 25, 2026 at 9:33 am

    The switch statement 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-elseif statements, like you’re already on your way to do.

    To do “range checks” in switch is really verbose:

    switch(windowWidth) {
        case 1:
        case 2:
        case 3:
        case 4:
        case 5:
            //Do something if value is less than or equal to 5
            break;
        case 6:
        case 7:
        case 8:
        case 9:
        case 10:
            //Do something if value is higher than 5 AND less than or equal to 10
            break;
        ...
        ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to check what colors is present in a image. This will
I would like to check if my paragraph tag is empty using Jquery. Meaning
how to check if window is on top through usercontrol i would like to
I would like to change the page title for the openned window when a
How do you check if an opencv window has been closed? I would like
I would like to check which type of RAM my computer uses before I
I would like to check my JavaScript files without going to JSLint web site.
I would like to check whether an object (e.g. someObject ) is assignable (cast-able)
I would like to check if a few URL's exst on my old website
I would like to check whether the request is XML od HTML. When HTML

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.