15 hours ago · 5 min read1014 words · Tech · hide · 0 comments

Earlier today and in a non web-related conversation, I saw someone talk about copying tabular data into different formats, like plain text and CSV. It got me thinking - this could be a useful feature for web sites and surely something pretty trivial to do in JavaScript. So I whipped up a quick demo. First, I added a table of course: <table id="table1"> <thead> <tr> <th>Name</th> <th>DOB</th> <th>Gender</th> <th>Breed</th> </tr> </thead> <tbody> <tr><td>Whiskers</td><td>2019-03-14</td><td>Male</td><td>Maine Coon</td></tr> <tr><td>Luna</td><td>2020-07-22</td><td>Female</td><td>Siamese</td></tr> <!-- bunch more rows --> <tr><td>Nala</td><td>2022-04-18</td><td>Female</td><td>Persian</td></tr> <tr><td>Molly</td><td>2022-01-11</td><td>Female</td><td>LaPerm</td></tr> </tbody> </table> Alright, so to enable this feature, I thought data attributes might be nice. This would let you use it on anything, a button, a link, image, etc. The data attribute would be responsible for pointing to the…

No comments yet. Log in to reply on the Fediverse. Comments will appear here.