• <legend id='ZpFhg'><style id='ZpFhg'><dir id='ZpFhg'><q id='ZpFhg'></q></dir></style></legend>

    1. <tfoot id='ZpFhg'></tfoot>

    2. <small id='ZpFhg'></small><noframes id='ZpFhg'>

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

        多个 if 语句的替代方案

        Alternative for multiple if statements(多个 if 语句的替代方案)

              <small id='5TwPo'></small><noframes id='5TwPo'>

                <tbody id='5TwPo'></tbody>
                <bdo id='5TwPo'></bdo><ul id='5TwPo'></ul>
                  <legend id='5TwPo'><style id='5TwPo'><dir id='5TwPo'><q id='5TwPo'></q></dir></style></legend>
                1. <i id='5TwPo'><tr id='5TwPo'><dt id='5TwPo'><q id='5TwPo'><span id='5TwPo'><b id='5TwPo'><form id='5TwPo'><ins id='5TwPo'></ins><ul id='5TwPo'></ul><sub id='5TwPo'></sub></form><legend id='5TwPo'></legend><bdo id='5TwPo'><pre id='5TwPo'><center id='5TwPo'></center></pre></bdo></b><th id='5TwPo'></th></span></q></dt></tr></i><div id='5TwPo'><tfoot id='5TwPo'></tfoot><dl id='5TwPo'><fieldset id='5TwPo'></fieldset></dl></div>

                2. <tfoot id='5TwPo'></tfoot>
                3. 本文介绍了多个 if 语句的替代方案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我的代码包含很多多个 if 语句.有没有其他方法可以摆脱这些陈述.例如假设我有以下条件

                  My code contains a lot of multiple if statements. Is there any other way to get rid of these statements. For example suppose I have the following conditions

                  if(t1 >= 1 && t2 == 0 && t3 == 0) $('div.b_class').fadeIn();
                  if(t1 == 0 && t2 >= 1 && t3 == 0) $('div.c_class').fadeIn();
                  if(t1 == 0 && t2 == 0 && t3 == 1) $('div.d_class').fadeIn();
                  if(t1 && t2 >= 1 && t3 == 0) $('div.b_class.c_class').fadeIn();
                  if(t1 && t3 >= 1&& t2 == 0) $('div.b_class.d_class').fadeIn();
                  

                  有什么方法可以简化这些语句?

                  Is there any way to simplify these statements?

                  推荐答案

                  你可以像这样使用带有条件的 switch case 结构:

                  You could use a switch case structure with conditions inside like this :

                  switch(true)
                  {
                   case (t1 >= 1 && t2 == 0 && t3 == 0) : $('div.b_class').fadeIn(); break;
                   case (t1 == 0 && t2 >= 1 && t3 == 0) : $('div.c_class').fadeIn(); break;
                   case (t1 == 0 && t2 == 0 && t3 == 1) : $('div.d_class').fadeIn(); break;
                   case (t1 && t2 >= 1 && t3 == 0)      : $('div.b_class.c_class').fadeIn(); break;
                   case (t1 && t3 >= 1&& t2 == 0)       : $('div.b_class.d_class').fadeIn(); break;
                  }
                  

                  这篇关于多个 if 语句的替代方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  在开发JS过程中,会经常遇到两个小数相运算的情况,但是运算结果却与预期不同,调试一下发现计算结果竟然有那么长一串尾巴。如下图所示: 产生原因: JavaScript对小数运算会先转成二进制,运算完毕再转回十进制,过程中会有丢失,不过不是所有的小数间运算会
                  append() 方法在被选元素的结尾(仍然在内部)插入指定内容。 语法: $(selector).append( content ) var creatPrintList = function(data){ var innerHtml = ""; for(var i =0;i data.length;i++){ innerHtml +="li class='contentLi'"; innerHtml +="a href
                  问题描述: 在javascript中引用js代码,然后导致反斜杠丢失,发现字符串中的所有\信息丢失。比如在js中引用input type=text onkeyup=value=value.replace(/[^\d]/g,) ,结果导致正则表达式中的\丢失。 问题原因: 该字符串含有\,javascript对字符串进行了转
                  Rails/Javascript: How to inject rails variables into (very) simple javascript(Rails/Javascript:如何将 rails 变量注入(非常)简单的 javascript)
                  CoffeeScript always returns in anonymous function(CoffeeScript 总是以匿名函数返回)
                  Ordinals in words javascript(javascript中的序数)

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

                    <legend id='50rr4'><style id='50rr4'><dir id='50rr4'><q id='50rr4'></q></dir></style></legend>
                      <bdo id='50rr4'></bdo><ul id='50rr4'></ul>

                        <small id='50rr4'></small><noframes id='50rr4'>

                        <tfoot id='50rr4'></tfoot>