skip to Main Content

The code just doesn’t execute. I click the button and it doesn’t put up an alert. I tried document.write, too.

function canvasAlert() {
  alert("link");
}
<p><input type="button" id="canvasAlert" value="Canvas"></p>

2

Answers


  1. Chosen as BEST ANSWER

    I figured it out, im stupid LOL.

    I needed a onclick to reference the functon in the html code and the id being something to diversify multiple inputs (i think..?)


  2. <body>
      <p><input type="button" id="canvasAlert" value="Canvas" 
    **onclick="canvasAlert()"**></p>
    
    <script>
    function canvasAlert() {
      alert("link");}
    </script>
    </body>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search