正则表达式判定保留2位小数的实现代码

栏目: 编程语言 · 正则表达式 · 发布时间: 8年前

内容简介:这篇文章主要介绍了正则表达式判定保留2位小数的实现代码,需要的朋友可以参考下

废话不多说了,直接给大家贴代码了,具体代码如下所示:

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script type="text/javascript" src="js/jquery.min.js" ></script>
</head>
<body>
<li><a class="ba">6.88888888</a></li>
<script>
var b=$('.ba').html();
onload = function(){   
var a = b;
  var aNew;
  var re = /([0-9]+\.[0-9]{2})[0-9]*/;
  aNew = a.replace(re,"$1");
  $(".ba").html(aNew)
 } 
</script>
</body>
</html>

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Beginning Google Maps API 3

Beginning Google Maps API 3

Gabriel Svennerberg / Apress / 2010-07-27 / $39.99

This book is about the next generation of the Google Maps API. It will provide the reader with the skills and knowledge necessary to incorporate Google Maps v3 on web pages in both desktop and mobile ......一起来看看 《Beginning Google Maps API 3》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具