zoukankan      html  css  js  c++  java
  • JS截取字符串

    //两种写法ie和firefox、Google都支持(js截取字符串)

    /*

    //一下方法是:

    //对一个数字类型的进行操作,取最后一位。。。。。。。。,对数字的处理方式是,把数字转成字符串然后取最后一位,而ie不支持传统取法。

    */

    //ieTMD不支持这种写法

    var mFloorOne = Math.floor(r*100);//向下取整

     

                      /*var rightOne = mFloorOne.toString()[(mFloorOne.toString().length-1)];

                      var one = rightOne-5==0;

                      var mFloorTwo = Math.floor(r*10);//向下取整

                      var rightTwo = mFloorTwo.toString()[(mFloorTwo.toString().length-1)];*/

    ie支持

    var mFloorOne = Math.floor(r*100);//向下取整

                      //alert("mFloor"+mFloorOne+"length"+(mFloorOne.toString().length-1));

                      //ieTMD不支持这种写法

                      /*var rightOne = mFloorOne.toString()[(mFloorOne.toString().length-1)];

                      var one = rightOne-5==0;

                      var mFloorTwo = Math.floor(r*10);//向下取整

                      var rightTwo = mFloorTwo.toString()[(mFloorTwo.toString().length-1)];*/

                      var rightOne = mFloorOne.toString().charAt((mFloorOne.toString().length-1));

                      alert("right"+rightOne);

                      var one = rightOne-5==0;

                      alert("two"+one);

                      var mFloorTwo = Math.floor(r*10);//向下取整

                      var rightTwo = mFloorTwo.toString().charAt((mFloorTwo.toString().length-1));

    好长时间不写了啊!

  • 相关阅读:
    solution for "cannot find vcvarsall.bat" in Python
    fast debug a program with GDB
    pLSA 浅析
    argsort in Python
    how to create html from tex source file
    google云输入法以及在chrome中的插件
    贝叶斯估计浅析
    JavaScript学习篇(5)
    JavaScript学习篇(6)
    JavaScript学习篇(2)
  • 原文地址:https://www.cnblogs.com/wangliansong/p/3517171.html
Copyright © 2011-2022 走看看