0

I have the following HTML table row data (within a proper table (table > tbody > tr) of course):

<tr id="uo_311" data-id="311" data-price="250.01111100" data-qty="1.00000000" data-value="250.26112211">
  <td>....</td>
  ....
</tr>

and the following jquery code to loop through the existing rows and find the place to insert a new row based on price (table is sorted by price):

var price = parseFloat(response['price']);
var elTable = $('#openTable');
var tableRowCount = elTable.find('tbody > tr').length;
for (var i = 0; i < tableRowCount; i++) {
    var row      = elTable.find("tbody > tr").eq(i);
    var rowPrice = parseFloat(row.data('price'));
    if (price > rowPrice) {
        row.before('<tr><td>NEW ROW</td></tr>');
        break;
    }
 }

The basic logic of this seems to work OK, but for some reason the statement

var rowPrice = parseFloat(row.data('price'));

returns NaN. Does anybody have any idea what I'm doing wrong here?

Erik Philips
  • 53,428
  • 11
  • 128
  • 150
user13955
  • 860
  • 2
  • 9
  • 25

0 Answers0