专家。JavaScript无法产生所需的延迟效果。从其他问题上,我由此知道,问题在于settimeout及其使用方式。但我仍然无法理解Settimeout的工作原理。所以我将代码放在这里。由于知识目的,仅需使用Javascript。实际上,我正在尝试清除有关此的概念,即javascript中的闭包。它们是Java的扭曲事物吗?var objImg = new Object();var h;var w;var no = 100;while (no != 500) { setTimeout(function () { size(no, no); }, 2000); /* it's get executed once, instead of repeating with while loop Does it leave loop in mid? I get image with 500px height and width, but effect is not acheived. */ no = no + 50;}function size(h, w) { var objImg = document.getElementsByName('ford').item(0); objImg.style.height = h + 'px'; objImg.style.width = w + 'px';}
添加回答
举报
0/150
提交
取消