简体   繁体   中英

How to call JavaScript function from a .HTML file to a .JS file?

I've been working on a.js and.html file and in my.js file, I want to call to a function that's located in the.html file.

This is the function in the.html file that I want to be called to:

    <script>
        function themeChange4() {
            document.getElementById("theStyle").style = "";
        }
    </script>

This is where I want the function to be called to in my.js file:

add_icon_not_via_filesystem({
    title: "Vending Machine",
    icon: "Soda",
    open: themeChange4,
});

If I understood You want from HTML

  <script src="js.js"></script>
  <script>
  function themeChange4(){
     add_icon_not_via_filesystem(); 
  }
themeChange4();
 </script>

to call

function add_icon_not_via_filesystem(){
 alert('This');
 }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM