Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>
<button id = "id_button">Button</button>
<input type = "text" id = "id_input" />
</body>
</html>
 
window.Element.prototype.one = function(event, callback){
    this.addEventListener(event, this.call = function(){
        callback();
        this.removeEventListener(event, this.call, false);
    }, false);    
};
var button = document.getElementById("id_button"),
    input = document.getElementById("id_input");
button.one("click", function(){
    alert("Botón. Solo verás este mensaje una vez.");
});
input.one("focus", function(){
    alert("Input. Solo verás este mensaje una vez.");
});
Output

This bin was created anonymously and its free preview time has expired (learn why). — Get a free unrestricted account

Dismiss x
public
Bin info
anonymouspro
0viewers