Answers for "how to add stylesheet to a different html file in js"

7

javascript css link append

document.getElementsByTagName("head")[0].insertAdjacentHTML(
    "beforeend",
    "<link rel=\"stylesheet\" href=\"path/to/style.css\" />");
Posted by: Guest on March-20-2020
0

add css style sheet with javascript

<head>

<script>
function myFunction() {
  var x = document.createElement("LINK");
  x.setAttribute("rel", "stylesheet");
  x.setAttribute("type", "text/css");
  x.setAttribute("href", "styles.css");
  document.head.appendChild(x);
}
myFunction()
</script>

</head>
Posted by: Guest on June-12-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language