What do you want to save?
Add Code snippet
New code examples
-
Javascript 2022-03-01 07:55:16
appendchild element once if element present in js
//insert new Element after some reference Element function insertAfter(newElement, referenceElement) { referenceElement.parentNode.insertBefore(newElement, referenceElement.nextSibling); } //example usage var newElement = document.createElement("... Add solution -
Javascript 2022-02-27 23:00:02
js copy to clipboard cross browser
/** copy text to the clipboard */ function copy2clipboard( text, callback /* optional */ ) { // use modern clipboard API if ( navigator.clipboard ) { navigator.clipboard.writeText( text ) .then( function(){ // if a callback is provided, call it ... Add solution -
Javascript 2022-02-20 04:40:15
convert an image into Base64 string using JavaScript
function getBase64Image(src, callback, outputFormat) { const img = new Image(); img.crossOrigin = 'Anonymous'; img.onload = () => { const canvas = document.createElement('canvas'); const ctx = canvas.getContext('2d'); ... Add solution -
Javascript 2022-02-17 10:00:02
injected stylesheet remove
/* Answer to: "injected stylesheet remove" */ function loadCSS(file) { var link = document.createElement("link"); link.href = chrome.extension.getURL(file + '.css'); link.id = file; link.type = "text/css"; link.rel... Add solution -
Html 2022-02-02 23:25:17
json object in html page
function appendData(data) { var mainContainer = document.getElementById("myData"); for (var i = 0; i < data.length; i++) { var div = document.createElement("div"); div.innerHTML = 'Name: ' + data[i].firstName + ' ' + dat... Add solution -
TypeScript 2022-02-02 23:00:06
typescript operate with html objects
ts// 1. Select the div element using the id property const app = document.getElementById("app"); // 2. Create a new <p></p> element programmatically const p = document.createElement("p"); // 3. Add the text content p.text... Add solution -
Javascript 2022-02-02 21:05:02
Inserting HTML elements with JavaScript
function create(htmlStr) { var frag = document.createDocumentFragment(), temp = document.createElement('div'); temp.innerHTML = htmlStr; while (temp.firstChild) { frag.appendChild(temp.firstChild); } return frag; } var... Add solution
Best helpers
Holyeyeolo
+5
Auntkym
+5
Mostafa 36a2
+5
Rodrigorgs
+5
Matt2507864
+5
Arnav Bose
+5
Waldrumpus
+5
TheShade
+5
Naigel
+5
Babak
+5
Ohhh
+5
Jeff Sours
+5
Jim Mourgos
+5
J. Marks
+5
Piquet
+5