Entries by Génesis

Export HTML table to CSV file

Imagine you have an HTML table, for example something like this: <table> <tr><th>Name</th><th>Age</th><th>Country</th></tr> <tr><td>Geronimo</td><td>26</td><td>France</td></tr> <tr><td>Natalia</td><td>19</td><td>Spain</td></tr> <tr><td>Silvia</td><td>32</td><td>Russia</td></tr> </table> And you want to download it as a CSV table format. First of all, you need to transform from HTML to CSV. var csv = []; var rows = document.querySelectorAll(“table tr”); for (var i = 0; i < […]

Short selectors like jQuery

Using JavaScript is some kind of annoying when you have to select DOM elements, in those cases we could miss jQuery because JavaScript is simply too long. // Select one element document.querySelector(“#peter”); document.querySelector(“.staff”); // get the first one document.querySelector(“.staff”).querySelector(“#age”); // Select all elements document.querySelectorAll(“.staff”) // get an array We don’t like to repeat things when […]

Looking for a string inside another string

If you want to find a string inside another string, there are many options available, each one will depend on the result and performance you are looking for. Use test if you want just to know if the string exists (true) or not (false). Use exec if you want to get the string you are looking […]

How to make a mobile app?

In this tutorial I’m going to explain you step by step how I make phone apps using Cordova (Phonegap/Ionic) and Ubuntu. 1) Install Cordova For those who don’t know anything about Cordova, it is an opensource platform for building multiple platforms applications using HTML, CSS and JavaScript. The main different between Cordova and Phonegap is […]