Answers for "include js"

59

include script in html

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

include js in html

<html>
    <head>        
    </head>
    <body>
    
        <script type="text/javascript" src=es4.js></script>
           
    </body>
        
</html>
Posted by: Guest on January-26-2021
28

javascript contains substring

var str = "We got a poop cleanup on isle 4.";
if(str.indexOf("poop") !== -1){
	alert("Not again");
}
//use indexOf (it returns position of substring or -1 if not found)
Posted by: Guest on July-18-2019
10

how to add script in html head

<script src="script.js" defer></script>

<!--just add defer attribute so script will execute at last-->
Posted by: Guest on August-21-2020
2

include js to js

var imported = document.createElement('script');
imported.src = '/path/to/imported/script';
document.head.appendChild(imported);
Posted by: Guest on July-15-2021
34

javascript includes

const pets = ['cat', 'dog', 'bat'];

console.log(pets.includes('cat'));
// output: true
Posted by: Guest on June-12-2020

Browse Popular Code Answers by Language