Javascript examples for DOM HTML Element:Link
You can create a <link> element by using the document.createElement() method:
<!DOCTYPE html> <html> <head> </head>//from w w w . j a v a 2 s.c o m <body> <button onclick="myFunction()">create a LINK element</button> <script> function myFunction() { var x = document.createElement("LINK"); x.setAttribute("rel", "stylesheet"); x.setAttribute("type", "text/css"); x.setAttribute("href", "http://java2s.com/style/bootstrap.min.css"); document.head.appendChild(x); } </script> </body> </html>