lundi 29 juin 2015

How do I implement external js file in html webpage?

I created the following JS in an external file:

var n = Math.floor((Math.random() * 1000) + 1); { window.alert(n);
if (n) var output = ""; if (n % 3 == 0) output += "Rock"; if (n % 5 == 0) output += "star"; window.alert(output || n); }

I want to implement this code when a person clicks a button on the webpage.

Would I use need to place this into my html page: Click me?

Aucun commentaire:

Enregistrer un commentaire