Javascript

4 Ways To Remove Line Breaks In Javascript

Welcome to a quick tutorial on how to remove line breaks in Javascript. Want to remove all line breaks and create a “flat string” in Javascript? There are actually a few ways to do it: STRING.replace(/\r?\n|\r/, “”); STRING.replaceAll(“\r”, “”).replaceAll(“\n”, “”); To remove HTML line breaks – STRING.replaceAll(“<br>”, “”).replaceAll(“<br/>”, “”); To remove only leading and trailing

4 Ways To Remove Line Breaks In Javascript Read More »

Non-Editable Text Field In HTML Javascript (Disabled & Readonly)

Welcome to a quick tutorial on how to create a non-editable text field in HTML and Javascript. Want to “fix” a text field in HTML or Javascript? Prevent the user from changing the value? To create a non-editable text field in HTML, we can either attach the readonly or disabled attribute. <input type=”text” readonly> <input

Non-Editable Text Field In HTML Javascript (Disabled & Readonly) Read More »

5 Ways To Change Override CSS With Javascript (Simple Examples)

Welcome to a quick tutorial on how to change or override CSS with Javascript. Want to dynamically update or change some styles on a web page? The common ways to change or override CSS in Javascript are: document.getElementById(“ID”).style.PROPERTY = “VALUE”; document.getElementById(“ID”).style.cssText = “PROPERTY: VALUE”; document.getElementById(“ID”).setAttribute(“style”, “PROPERTY: VALUE”); document.getElementById(“ID”).className = “CLASS”; document.documentElement.style.setProperty(“–VAR”, “VALUE”); That covers the

5 Ways To Change Override CSS With Javascript (Simple Examples) Read More »