Need help selecting numbers only in a div element

Need help selecting numbers only in a div element

Hey Guys. I have a quick question. I am trying to select a float in a div element that also contains a string. Is there a way I can filter so it just get the number?

Another alternative is to wrap the floating number in a separate element, but I would rather use jQuery to filter out the text so it can get the number.

Below is my HTML code

  1. <div id="grand_total" class="totals">Grand Total = $7.57</div>


  1. $('#tip').change(function() {
        var $tip = $('#tip').val();
        var $total_amount = $('#grand_total').text()
       var $total =  parseFloat($total_amount) + parseFloat($tip);
       console.log($total);
       // $('#grand_total').html($total);
    });
    Right now it returns NaN