-1

Right I have no clue where to start when it comes to regex but I'm assuming this is the right way to go with this... I'm trying to split html with javascript I'm retriving the html element like so:

$('.HomeFeaturedPrice').each(function(index, el) {
 var grabPrice = $(this).html();
 var convertPrice = Number(grabPrice);
 console.log(convertPrice);
});

convertPrice could output to different options now:

option one is: $50.00

option two is: <span id="salesprice">$50.90</span> How do i write a regex to pick up on the price only.... stripping out all the html and the dollar sign... Chris

Dairo
  • 822
  • 1
  • 9
  • 22
vimes1984
  • 1,684
  • 3
  • 26
  • 59

1 Answers1

1

You don't need RegEx for something this simple. You can just do the following.

var salesPrice = $("#salesprice").text();

This will make the salesPrice variable equal to whatever is between the span elements.

Justin Wood
  • 9,941
  • 2
  • 33
  • 46