Blocking default click handling

by somya_kashyap3

HTML

<!-- Learn about this code on MDN: https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault -->

<p>Please click on the checkbox control.</p>

<form>
  <label for="id-checkbox">Checkbox:</label>
  <input type="checkbox" id="id-checkbox"/>
</form>

<div id="output-box"></div>

JavaScript

document.querySelector("#id-checkbox").addEventListener("click", function(event) {
				event.preventDefault();
         document.getElementById("output-box").innerHTML += "Sorry! <code>preventDefault()</code> won't let you check this!<br>";
         
}, false);