Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * @name table2csv
- * @descripton Converts an html table to CSV
- * @version 0.1
- * @requires jQuery
- *
- * @author John Ballantyne
- * @author-email johnballantyne@gmail.com
- *
- * @licence MIT License - http://www.opensource.org/licenses/mit-license.php
- */
- (function( $ ) {
- $.fn.table2csv = function(selector) {
- var output = ""
- $(selector).each(function() {
- var $rows = $(this);
- var $ele = $rows.children();
- $ele.each(function() {
- var cell = $(this).html().replace(/\$|,/g, "");
- // cell = cell.replace(/$/g, "");
- output += cell + ",";
- });
- output += ";";
- });
- output = output.replace(/,;/g, ";");
- return output;
- };
- })( jQuery );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement