So my ultimate goal is to have a simple web page with 10 buttons and each button, after clicking on it another javascript function is called. Each of these functions will be a kind of pattern. For starters, I'm just trying to get used to the buttons that invoke external js files.
<html>
<head>
<script type = "text/javascript" src="/Users/myname/Downloads/p5-release 3/empty-example/sketch.js">
</script>
</head>
<body>
<button onclick="setup();draw();">
Draw me a circle!
</button>
</body>
</html>
Above is my html file, and below is the javascript file from which I am trying to call a function.
function setup() {
createCanvas(1300, 800);
}
function draw(){
ellipse(100,100,80,80);
}
A button appears, but nothing happens after it is pressed. I would like the button to disappear after clicking and only an ellipse remains. Is it possible? I am very new to web development (I started yesterday), so I'm sorry if this is a very simple problem to solve.
source
share