javascript新手,如何更改-> document.write(schedule [row] ['title']))的颜色;变成红色?

时间:2019-02-27 16:35:37

标签: javascript colors

我对javascript很陌生,我无法弄清楚如何更改for / in循环中第一个“ document.write”的颜色? -> document.write(schedule [row] ['title']); <-

var schedule = [], row, col;

var TECH276 = { title : "JavaScript Fundamentals",
                credits : 3,
                section : 1,
                days : "Thursday",
                time : "6:30 p.m. - 9:25 p.m.",
                semester : "Spring 2019",
                fascinating : true
            };

var TECH277 = { title : "Advanced Javascript",
                credits : 3,
                section : 1,
                days : "Thursday",
                time : "6:30 p.m. - 9:05 p.m.",
                semester : "Fall 2019",
                fascinating : true
            };

schedule[0] = TECH276;
schedule[1] = TECH277;

for (row in schedule) {
    document.write(schedule[row]['title']);
    document.write("<br />");
    for (col in schedule[row]) {
        document.write('The property ' + "<i>" + col + "</i>" + ' = <b>'+ schedule[row][col] + "</b>&nbsp; &nbsp; <br>");
    }
    document.write("<br />");
}

1 个答案:

答案 0 :(得分:1)

只需将其包装在P中并设置样式:

span