skip to Main Content

Create SVG, set href instead of xlink:href in pure Javascript

I have an SVG sprite with all my icons, and when dinamically adding an icon in Javascript I use thise code: let closeButton = document.createElementNS("http://www.w3.org/2000/svg", "svg"); let svgUse = document.createElementNS('http://www.w3.org/2000/svg', 'use'); svgUse.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', 'css/sprite.svg#warning'); closeButton.append(svgUse); I think can understand straight…

VIEW QUESTION

Javascript – How to switch an svg to another svg after clicking on it?

I have this sun svg image that switches the page to dark mode: <svg onclick="myFunction()" width="24" height="24" viewBox="0 0 24 24" fill="#000" xmlns="http://www.w3.org/2000/svg"> <path d="M12 3V5.25M18.364 5.63604L16.773 7.22703M21 12H18.75M18.364 18.364L16.773 16.773M12 18.75V21M7.22703 16.773L5.63604 18.364M5.25 12H3M7.22703 7.22703L5.63604 5.63604M15.75 12C15.75 14.0711 14.0711…

VIEW QUESTION

Html – Favico Not Showing Until Cache is Cleared Every Time

I have a page where the index.html has a head tag, which contains a link tag with a favico.svg: <link rel="manifest" href="./manifest.json"> <link rel="shortcut icon" type=“image/x-icon” href="./images/Site_Favicon.svg"> <link rel="icon" type=“image/x-icon” href="./images/Site_Favicon.svg"> and in manifest.json I have: "icons": [ { "src":…

VIEW QUESTION
Back To Top
Search