• <i id='pUibA'><tr id='pUibA'><dt id='pUibA'><q id='pUibA'><span id='pUibA'><b id='pUibA'><form id='pUibA'><ins id='pUibA'></ins><ul id='pUibA'></ul><sub id='pUibA'></sub></form><legend id='pUibA'></legend><bdo id='pUibA'><pre id='pUibA'><center id='pUibA'></center></pre></bdo></b><th id='pUibA'></th></span></q></dt></tr></i><div id='pUibA'><tfoot id='pUibA'></tfoot><dl id='pUibA'><fieldset id='pUibA'></fieldset></dl></div>

    <small id='pUibA'></small><noframes id='pUibA'>

      <tfoot id='pUibA'></tfoot>
        <bdo id='pUibA'></bdo><ul id='pUibA'></ul>
    1. <legend id='pUibA'><style id='pUibA'><dir id='pUibA'><q id='pUibA'></q></dir></style></legend>
      1. 如何检测窗口大小然后用 jquery switch 语句做一些事情

        How to detect window size and then do something with jquery switch statement(如何检测窗口大小然后用 jquery switch 语句做一些事情)

        <tfoot id='grz5F'></tfoot>

            <tbody id='grz5F'></tbody>

          <small id='grz5F'></small><noframes id='grz5F'>

          <i id='grz5F'><tr id='grz5F'><dt id='grz5F'><q id='grz5F'><span id='grz5F'><b id='grz5F'><form id='grz5F'><ins id='grz5F'></ins><ul id='grz5F'></ul><sub id='grz5F'></sub></form><legend id='grz5F'></legend><bdo id='grz5F'><pre id='grz5F'><center id='grz5F'></center></pre></bdo></b><th id='grz5F'></th></span></q></dt></tr></i><div id='grz5F'><tfoot id='grz5F'></tfoot><dl id='grz5F'><fieldset id='grz5F'></fieldset></dl></div>

            1. <legend id='grz5F'><style id='grz5F'><dir id='grz5F'><q id='grz5F'></q></dir></style></legend>

                  <bdo id='grz5F'></bdo><ul id='grz5F'></ul>
                  本文介绍了如何检测窗口大小然后用 jquery switch 语句做一些事情的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想使用 jquery 检查窗口大小,并根据不同的分辨率更改背景图像.所以我想以某种方式在更多情况下使用switch"语句,但我只是不知道这会是什么样子.这是我想要的基本结构,但有更多选择:

                  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
                  }
                  

                  感谢您的帮助.

                  推荐答案

                  switch 语句不会让你做诸如检查特定值之间的数字之类的事情,它也不会让你检查在多个变量上,要么...

                  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...

                  所以对于这个特定的场景,我认为最合适的实际上只是一个 if-elseif 语句的列表,就像你已经在做的那样.

                  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.

                  switch 中进行范围检查"真的很冗长:

                  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;
                      ...
                      ...
                  }
                  

                  这篇关于如何检测窗口大小然后用 jquery switch 语句做一些事情的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Youtube iframe api not triggering onYouTubeIframeAPIReady(Youtube iframe api 未触发 onYouTubeIframeAPIReady)
                  Is returning out of a switch statement considered a better practice than using break?(从 switch 语句中返回是否被认为是比使用 break 更好的做法?)
                  Why Switch statement only working with true keyword?(为什么 Switch 语句仅适用于 true 关键字?)
                  Switch case jumps to wrong case in javascript (how to properly use the break command)(javascript中switch case跳转到错误大小写(如何正确使用break命令))
                  javascript fizzbuzz switch statement(javascript fizzbuzz switch 语句)
                  Compact a switch case in javascript(在 javascript 中压缩一个开关盒)

                    <tbody id='ITlyK'></tbody>
                    1. <legend id='ITlyK'><style id='ITlyK'><dir id='ITlyK'><q id='ITlyK'></q></dir></style></legend>
                      <tfoot id='ITlyK'></tfoot>
                        <bdo id='ITlyK'></bdo><ul id='ITlyK'></ul>

                          • <small id='ITlyK'></small><noframes id='ITlyK'>

                          • <i id='ITlyK'><tr id='ITlyK'><dt id='ITlyK'><q id='ITlyK'><span id='ITlyK'><b id='ITlyK'><form id='ITlyK'><ins id='ITlyK'></ins><ul id='ITlyK'></ul><sub id='ITlyK'></sub></form><legend id='ITlyK'></legend><bdo id='ITlyK'><pre id='ITlyK'><center id='ITlyK'></center></pre></bdo></b><th id='ITlyK'></th></span></q></dt></tr></i><div id='ITlyK'><tfoot id='ITlyK'></tfoot><dl id='ITlyK'><fieldset id='ITlyK'></fieldset></dl></div>