zoukankan      html  css  js  c++  java
  • js中判断字符串相等使用==

    在 javaScript或者jQuery中字符串比较没有equals()方法,要比较两个字符串是否相等可以直接用==或者is()进行判断。

    一段老的js代码示例:

    var items = document.getElementById("PDStatus").options;
      	if("1"==(<%=checkOut.getFILLER1().substring(10)%>) ){
      		items[1].selected =true;
      	}else if("2"==(<%=checkOut.getFILLER1().substring(10)%>)){
      		items[2].selected =true;
      	}else if("3"==(<%=checkOut.getFILLER1().substring(10)%>)){
      		items[3].selected =true;
      	}else{
      		items[0].selected =true;
      	}
    

    使用var filler1 = <%=checkOut.getFILLER1()%>; filler1的类型为obj;如果想要接受的filler为字符串,应该使用如下写法

    var filler1 = "<%=checkOut.getFILLER1()%>";
    

    而非:

    var filler1 = <%=checkOut.getFILLER1()%>+"0";
    
  • 相关阅读:
    Maven的生命周期
    Maven坐标
    IDEA配置maven
    IDEA配置tomcat
    重写父类方法
    类的继承
    内部类
    static关键字
    线程相关知识
    数组
  • 原文地址:https://www.cnblogs.com/DiZhang/p/12544891.html
Copyright © 2011-2022 走看看