javascript - How to export html value(not table) to a csv file with jquery? -


i have page user can dynamic add or edit html value below, , need save database, found way- php read csv file , update database, problem

how export html value(not table) csv file jquery?

<div class="list">     <div class="number">1</div>     <div class="text">a</div>     <div class="text">a</div> </div> <div class="list">     <div class="number">1</div>     <div class="text">a</div>     <div class="text">a</div> </div> .. 

if don't have comma-containing strings:

var csv = jquery(".list").map(function(a,i){   return $.trim($(this).text()).split(/\s*\n\s*/).join(","); }).toarray().join("\r\n");  alert(csv); 

you can use downloader @ http://danml.com/js/download.js download csv variable like:

 download(csv, "tabledata.csv", "text/csv"); 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -