<!DOCTYPE html> <html> <head> <title> </title> <meta charset=utf-8> </head> <body> <table> <tr> <th>A</th> <th>B</th> <th>C</th> </tr> <tr> <td>Line #1</td> <td>SLTD</td> <td>32</td> </tr> <tr> <td>Line #2</td> <td>MKTD</td> <td>68</td> </tr> <tr> <td>Line #3</td> <td>LRTD</td> <td>55</td> </tr> <tr> <td>Line #4</td> <td>HAD</td> <td>47</td> </tr> </table> <button>Export to text file</button> <script> var theFirstChilds = document.querySelectorAll('table tr td:first-of-type'), text, i; text = ""; for (i = 0; i < theFirstChilds.length; ++i) { text = text + theFirstChilds[i].innerText; } console.log(text); var button = document.getElementsByTagName("button")[0]; button.addEventListener("click", function() { //alert("I want to export the variable text [console.log(text)] to text file"); }); </script> </body> </html> Everything is working properly... The only thing that left is to export it to a text file...
iow... everything in the variable text would be saved to text file...
Single line solution would be perfect :)
Thanks !