正则表达式判定保留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>
相关推荐
wangzhaotongalex 2020-10-20
wyq 2020-11-11
TLROJE 2020-10-26
风雨断肠人 2020-10-13
duanqingfeng 2020-09-29
rechanel 2020-11-16
cshanzhizi 2020-10-16
luofuIT成长记录 2020-09-22
phphub 2020-09-10
taomengxing 2020-09-07
MaggieRose 2020-08-19
flyingssky 2020-08-18
山水沐光 2020-08-18
jyj00 2020-08-15
AHuqihua 2020-08-09
山水沐光 2020-08-03