HTML:
<div id="myID" onclick="cc(this.id)">Click Here</div>
JavaScript:
var timer;
var firing = false;
var begen = function(id) {
alert('tek');
};
var popupAc = function(id) {
alert('çift');
};
function cc(id) {
if (firing) {
popupAc(id);
clearTimeout(timer);
firing = false;
return;
}
firing = true;
timer = setTimeout(function() {
//begen(id);
clearTimeout(timer);
firing = false;
}, 250);
}
错误:
Uncaught ReferenceError: cc is not defined
示例:http: //jsfiddle.net/LXSZj/3/