我正在尝试将 div 放在表格单元格中。div 比表格单元格大,我希望表格单元格不调整大小,但保持与 div 漂浮在表格上相同的大小。我如何操作 CSS 和元素来做到这一点?
我试图最终让这个代码工作:
function Timer(callback, delay) {
var timerId, start, remaining = delay;
this.pause = function() {
window.clearTimeout(timerId);
remaining -= new Date() - start;
};
this.resume = function() {
start = new Date();
timerId = window.setTimeout(callback, remaining);
};
this.resume();
}
var timer;
function onEvent(){
timer = new Timer(anotherEvent(), 5000);
}
Run Code Online (Sandbox Code Playgroud)
但这不起作用,所以我简化它以查看可能存在的问题,并将其归结为:
var timer;
function event(){
timer = window.setTimeout(anotherEvent(), 5000);
}
Run Code Online (Sandbox Code Playgroud)
它所做的只是另一个事件().
有任何想法吗?
function keypressCheck() {
var keyID = event.keyCode;
//space pressed
if (keyID == 32) {
anotherFunction();
}
}
Run Code Online (Sandbox Code Playgroud)
我希望anotherFunction()在按下空格键时运行,而不会发生页面滚动的默认操作.有没有办法做到这一点?
javascript ×3
css ×1
css-tables ×1
events ×1
html-table ×1
keyboard ×1
settimeout ×1
timer ×1
window ×1