Calling a function from one JavaScript file which requires another

前端 未结 2 1962
执笔经年
执笔经年 2021-01-17 19:55

I am trying to call a function written in one JavaScript file from another JavaScript file. I have the following code, but it doesn\'t work:

My HTML file



        
2条回答
  •  佛祖请我去吃肉
    2021-01-17 20:39

    I'm going to assume that's your entire HTML page.

    In order to have those scripts run, you need to have those JavaScript files in the same folder as your webpage, and to actually have a proper HTML page!

    In your HTML page, you need to include the references to your js1 and js2 files in either the head or body, and include the script you've written in the HTML page itself in the body so that it'll execute when it's loaded:

    
    
    
        
            
            
            
            
        
        
            
            
            
        
    
    

提交回复
热议问题