How to use the same JavaScript in multiple content pages?

JavascriptWeb DevelopmentFront End Technology

To use the same JavaScript in more than one page, add the js code in an external JavaScript file. Let’s say the following demo.js is our external JavaScript file −

function display() {
   alert("Hello World!");

Now add the external JavaScript file to the following HTML web page. In the same way, you can add it to multiple content page.

         <input type="button" value="Result" onclick="display()"/>
      <script src="demo.js">
Published on 16-Jan-2018 15:03:54