我最近创建了一个代码,用于在按不同的箭头键时调整分隔高度。 不幸的是,它实际上并没有这样做。未捕获的语法错误:意外的输入结束
我不知道我在做什么错在这里 - 它只是告诉我未捕获的语法错误:输入意外结束
的代码如下:
<html>
<head>
<title>Grow your own div</title>
<script>
var high = box.style.offsetHeight;
var wide = box.style.offsetWidth;
window.onkeydown = function(){
if (event.keyCode === 37){
if (box.style.offsetWidth > 0) {
wide = wide--;
box.style.offsetWidth = wide;
}
else {
box.style.offsetWidth = 1;
}
}
else if (event.keyCode === 38) {
high = high++;
box.style.offsetHeight = high;
}
else if (event.keyCode === 39) {
wide = wide++;
box.style.offsetWidth = wide;
}
else if (event.keyCode === 40) {
if (box.style.offsetHeight > 0) {
high = high--;
box.style.offsetHeight = high;
}
else {
box.style.offsetHeight = 1;
}
}
</script>
</head>
<body>
<div style="height:100px; width:100px; background-color:orange; position:relative" id="box">
</div>
</body>
</html>
我不是精通如果您想了解更多信息,请参阅我的个人资料,不论是JavaScript还是HTML。
请格式化您的代码。 – 2014-09-21 06:08:59
是的,请妥善格式化您的代码,以便我们可以通过您的代码... – 2014-09-21 06:11:25
您的大括号不均衡,如果您格式化您的代码,您将很容易看到它。 – 2014-09-21 06:12:42