Simple click event JS

by Ryan Brackett

HTML

<p id="button">Click</p>
<p id="demo"></p>

CSS

body {font-family: Arial;}
#button {cursor: pointer;}

JavaScript

var hello;

var greeting = "Hi"

hello = (val) => greeting + " " + val;



document.querySelector("#button").addEventListener("click", function() {
  
    document.querySelector("#demo").innerHTML = hello("there!");
  
});