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));

 

 

 

好长时间不写了啊!

JS截取字符串

上一篇:Servlet + JSP 数据分页的实现


下一篇:MySQL、SqlServer、Oracle三大主流数据库分页查询