JSFiddle - React, Tailwind, and code Playground

by wjddyd66

HTML

태그에 직접 Event걸기<br>
<input id='B1' type="button" onclick="func()" value="Button1"><br>
Script에서 Event 걸기<br>
<input id='B2' type="button" value="Button2">

JavaScript

var button = document.getElementById("B2");
button.addEventListener('click', func);

function func() {
  alert("버튼이 눌림");
}