How to call a Javascript function in a stack?

0 votes
asked Jul 31, 2017 in Stacks by mikmikkelsen (115 points)
retagged Sep 26, 2017 by q2aadmin

II am learning to do stacks.
And I have downloaded the following code online.
My question is how do I move the JAVA SCRIPT function into a java script file, and what code and how to call and enable the code (function) when it's not all in the HTML file in the stack.

<P> Click the button to trigger a function that will output "Hello World" in a p element with id = "demo". </ P>
<Button onclick = "myFunction ()"> Click me </ button>
<P id = "demo"> </ p>
Function myFunction () {
    Document.getElementById ("demo"). InnerHTML = "Hello World";
</ Script>

Regards, Michael

1 Answer

0 votes
answered Sep 26, 2017 by q2aadmin (6,045 points)
selected Oct 13, 2017 by q2aadmin
Best answer

You can add more templates to your stack. Each template can be a different type: CSS, Javascript, HTML, etc.

You can read more about on the Stacks API website. Here's a link to the template docs: