Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="addEventListener() doesn't run the same function more than once if added with the same condition">
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>addEventListener() example</title>
</head>
<body>
   <button>Click</button>
</body>
</html>
 
function showDialog() {
    console.log('showDialog');
}
function hideDialog() {
    console.log('hideDialog');
}
var button = document.querySelector('button');
// Different conditions
button.addEventListener('click', showDialog, true);
button.addEventListener('click', showDialog, false);
// Same conditions
button.addEventListener('click', hideDialog, false);
button.addEventListener('click', hideDialog, false);
Output

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

Dismiss x
public
Bin info
AurelioDeRosapro
0viewers