Javascript examples for RegExp:Match Number
Convert the text to an int with regex
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){//from www . j a va 2 s. com var cash = document.getElementsByClassName('cash')[0].innerHTML; var parser = parseFloat(cash.replace(/[^0-9|^.]/g, '')); console.log(parser); } </script> </head> <body> <div class="cash"> 1,123.23 </div> </body> </html>