jQuery to pure Javascript examples – 5

Get inner text // jQuery var text = $(“#myElm”).text(); // Pure javascript var text = document.getElementById(“myElm”).textContent; Set inner text // jQuery $(“#myElm”).text(“My text”); // Pure javascript document.getElementById(“myElm”).textContent = “My text”; Get inner HTML // jQuery…

jQuery to pure Javascript examples – 4

Add onclick event // jQuery $(“#myElm”).click(function(){ alert(“Hello world”); }); // Pure javascript document.getElementById(“myElm”).addEventListener(“click”, function() { alert(“Hello world!”); }, false); Get child node by index //jQuery var child = $(“#myElm”).eq(2); // Pure javascript var child =…

jQuery to pure Javascript examples – 3

In these examples we see how easy it is to display, hide or use the toggle without jQuery. Hide an item  // jQuery $(“#myElm”).hide(); // Pure javascript document.getElementById(“myElm”).style.display = “none”; Show an item // jQuery…

jQuery to pure Javascript examples – 2

With this post we continue the series of examples to replace jQuery with pure javascript. Add class // jQuery $(“#myElm”).addClass(“my-class”); // Pure Javascript document.getElementById(“myElm”).classList.add(“my-class”); Remove class from an element // jQuery $(“#myElm”).removeClass(“my-class”); // Pure Javascript…

Get unix micro time in VB.NET

Public Shared Function GetUnixMicroTime() As String Dim origin As DateTime = New DateTime(1970, 1, 1, 0, 0, 0, 0) Dim diff As TimeSpan = Now() – origin Return CStr(diff.TotalSeconds) End Function

Extract only numbers from a string in JavaScript

There are many ways to extract numbers from a string in JavaScript. Here’s the function we use: function ExtractOnlyNumbersFromString(txt) { var numbers = txt.match(/\d/g); return (numbers) ? numbers.join(“”) : “”; } ExtractOnlyNumbersFromString(“a 1 b 2…

Serving HTTP images in a HTTPS site

If you’re looking for a solution to load images over HTTPS then the free cache & proxy service at cdn.dotmaui.com/ip/ is exactly what you are looking for. Silmply to use,  .Maui Proxy will cache the…

Clear systemd journal

Journalctl is a utility for querying and displaying logs from journald, systemd’s logging service. Journal logs can take considerable amount of disk space. Here are some useful steps to free up space on ubuntu and…