HTML:
<div id="myID" onclick="cc(this.id)">Click Here</div>?
Run Code Online (Sandbox Code Playgroud)
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);
}
Run Code Online (Sandbox Code Playgroud)
错误:
Uncaught ReferenceError: cc is not defined
Run Code Online (Sandbox Code Playgroud)
javascript ×1