我不明白.toString(16)
確實在此代碼 -傳遞參數給.toString()做什麼?
var fade = function (node) {
var level = 1;
var step = function() {
var hex = level.toString(16); // ← This part
node.style.backgroundColor = '#FFFF' + hex + hex;
if (level < 15) {
level += 1;
setTimeout(step, 100);
}
};
setTimeout(step, 100);
};
fade(document.body);
參考:https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number/toString。 –