Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
  <style>
    #test {
      width: 200px;
      height: 200px;
      background: red;
      cursor: pointer;
    }
  </style>
</head>
<body>
  <div id="test"></div>
  <label><input id="block" type="checkbox" value="1"> Block click event</label>
  <script>
    //third-party script, cannot edit
    document.getElementById('test').addEventListener('click', function (e) {
      alert('clicked');
    });
  </script>
  <script>
    //my script, can edit
    document.getElementById('test').addEventListener('click', function (e) {
      if (document.getElementById('block').checked) {
        //block click event from third-party script
      }
    });
  </script>
</body>
</html>
Output 300px

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers