废话不多说了,直接给大家贴代码了,具体代码如下所示:
<!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>
原文链接:http://blog.csdn.net/power_it_xiang/article/detAIls/75013668