SoFunction
Updated on 2025-03-04

Regular expression determines the implementation code that retains 2 decimal places

I won’t say much nonsense, I will just post the code to you. The specific code is as follows:

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script type="text/javascript" src="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 = (re,"$1");
  $(".ba").html(aNew)
 } 
</script>
</body>
</html>

The above is the implementation code for retaining 2 decimal places that the editor introduces to you. I hope it will be helpful to you. If you have any questions, please leave me a message and the editor will reply to you in time. Thank you very much for your support for my website!