Is there a way to fire a single function once when any event is raised?
For example, if I have the following function: (demo in jsfiddle)
$('input').one('mouseup keyup', function(e){
console.log(e.type);
});
I'd like to only call the function once, regardless of which event fired it.
But according to the docs for .one()
:
If the first argument contains more than one space-separated event types, the event handler is called once for each event type.
So, currently the function will fire once for each event type.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…