I knocked out a quick jQuery plugin to do what you requested.
Source (and demo) at http://jsfiddle.net/raybellis/tF833/
For reference here, the (current) code is as follows:
(function($) {
$.fn.duell = function() {
return this.each(function() {
var timer = null;
var el = this;
var stopTimer = function() {
if (timer) {
clearTimeout(timer);
timer = null;
}
};
var startTimer = function() {
stopTimer();
timer = setTimeout(function() {
$(el).click();
}, 1000);
};
$(el).click(stopTimer);
$(el).hover(startTimer, stopTimer);
});
};
})(jQuery);
source
share