lightswitch05 / table-to-json

Serializes HTML tables into JSON objects.
http://lightswitch05.github.io/table-to-json/
MIT License
756 stars 172 forks source link

To add <td id="value" in json data #41

Closed Brhmts closed 7 years ago

Brhmts commented 7 years ago

Hi

Firstly , Thanks for this amazing plugin, It saved lots of time

This is not an issue. Just I need some advice. How Could I get the td values ( <td id ="value") from each row and add it in JSON data ?

lightswitch05 commented 7 years ago

@Brhmts use extractor feature.

$('table').tableToJSON({
  extractor : function(cellIndex, $cell) {
    // get id from the cell, if empty or non-existant, get the cell text
    return $cell.attr('id') || $cell.text();
  }
});