How to call external JavaScript function in HTML

前端 未结 2 1825
悲&欢浪女
悲&欢浪女 2020-12-02 23:14

I have a small chunk of code I can\'t seem to get working. I am building a website and using JavaScript for the first time. I have my JavaScript code in an external file \'M

2条回答
  •  遥遥无期
    2020-12-02 23:45

    In Layman terms, you need to include external js file in your HTML file & thereafter you could directly call your JS method written in an external js file from HTML page. Follow the code snippet for insight:-

    caller.html

    
    
    

    external.js

    function letMeCallYou()
    {
        alert("Bazinga!!!  you called letMeCallYou")
    }
    

    Result :

提交回复
热议问题