Answers for "link javascript to html and css"

59

include script in html

<script type="text/javascript" src="/path/to/script.js"></script>
Posted by: Guest on July-17-2020
4

how to link javascript to html and css

# Javascript
<script src="[file_name].js"></script>

# CSS
<link rel = "stylesheet" type="text/css" href = "style.css" />
Posted by: Guest on November-09-2020
2

link stylesheet in javascript

var cssId = 'myCss';  // you could encode the css path itself to generate id..
if (!document.getElementById(cssId))
{
    var head  = document.getElementsByTagName('head')[0];
    var link  = document.createElement('link');
    link.id   = cssId;
    link.rel  = 'stylesheet';
    link.type = 'text/css';
    link.href = 'http://website.com/css/stylesheet.css';
    link.media = 'all';
    head.appendChild(link);
}
Posted by: Guest on October-16-2020
2

link javascript to html

<script src="index.js"> </script>
Posted by: Guest on October-06-2020

Browse Popular Code Answers by Language