title: Export to csv in jQuery
body: <p>I am dynamically generating a div which is like :</p>
  
  <pre><code>&lt;div id='PrintDiv'&gt;
          &lt;table id="mainTable"&gt;
              &lt;tr&gt;
                  &lt;td&gt;
                      Col1
                  &lt;/td&gt;
                  &lt;td&gt;
                      Col2
                  &lt;/td&gt;
                  &lt;td&gt;
                      Col3
                  &lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;
                      Val1
                  &lt;/td&gt;
                  &lt;td&gt;
                      Val2
                  &lt;/td&gt;
                  &lt;td&gt;
                      Val3
                  &lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;
                      Val11
                  &lt;/td&gt;
                  &lt;td&gt;
                      Val22
                  &lt;/td&gt;
                  &lt;td&gt;
                      Val33
                  &lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;
                      Val111
                  &lt;/td&gt;
                  &lt;td&gt;
                      Val222
                  &lt;/td&gt;
                  &lt;td&gt;
                      Val333
                  &lt;/td&gt;
              &lt;/tr&gt;
          &lt;/table&gt;
      &lt;/div&gt;
  </code></pre>
  
  <p>And there are lot more elements on the page as well.
  Now, how can i get a csv file like this :</p>
  
  <pre><code>Col1,Col2,Col3
  Val1,Val2,Val3
  Val11,Val22,Val33
  Val111,Val222,Val333
  </code></pre>
  
  <p>using jQuery ?</p>
  
  <p>need a file save dailog box too,like this :</p>
  
  <p><img src="https://i.stack.imgur.com/Mr3Tl.png" alt="alt text"></p>
  
  <p>Thanks.</p>