Convert Html table to CSV via jQuery - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:html

Description

Convert Html table to CSV via jQuery

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <script type="text/javascript" src="https://code.jquery.com/jquery-1.10.1.js"></script> 
  <script type="text/javascript">
    $(window).load(function(){//from   ww  w .  java2  s.  co  m
var csv = 'testing,testing,testing';
var csvData = 'data:application/csv;charset=utf-8,' + csv;
var filename = 'test.csv';
$('.link').attr({
  'download': filename,
  'href': csvData,
  'target': '_blank'
});
    });

      </script> 
 </head> 
 <body> 
  <a class="link">Test</a>  
 </body>
</html>

Related Tutorials