var fade = function (node) { var level = 1; var step = function () { var hex = level.toString(16); node.style.backgroundColor = "#FFFF" + hex + hex; if(level < 15) { level += 1; setTimeout(step, 100); } }; setTimeout(step, 100); }; fade(document.body);定義一個函數,它設置一個DOM節點為黃色,然后把它漸變為白色
為什么有兩個setTimeout,分別是什么意思?
慕桂英3389331
2018-10-17 13:14:44