JS & Node

4 Ways To Duplicate HTML Elements In Javascript (Simple Examples)

Welcome to a tutorial on how to duplicate HTML elements. So you are working on a project that requires the creation of evil clones, probably to ease tasks like creating table rows and list items? An easy way to duplicate an HTML element in Javascript is to use the cloneNode() function: var original = document.getElementById(“ID”); […]

4 Ways To Duplicate HTML Elements In Javascript (Simple Examples) Read More »

6 Ways To Abort Javascript Execution (Simple Examples)

Welcome to a tutorial on how to abort Javascript execution. Need to manually stop a piece of script for some reason? Client-side Javascript does not have a native abort function, but there are various alternatives to abort Javascript execution: In a function, simply return false or undefined. Manually throw new Error(“ERROR”) in a function. Set

6 Ways To Abort Javascript Execution (Simple Examples) Read More »

Set & Get HTML Data Attributes In Javascript (Simple Examples)

Welcome to a quick tutorial on how to set and get HTML data attributes in Javascript. Want to insert your own custom property or data into HTML elements? To set data attributes in HTML, we define data-KEY=”VALUE” in the start tag. E.G. <div data-color=”red”> To set data attributes in Javascript, we set the dataset property.

Set & Get HTML Data Attributes In Javascript (Simple Examples) Read More »