【发布时间】:2013-08-08 15:31:53
【问题描述】:
对于我的 JS html5 类,我正在尝试创建一个网页,允许用户选择背景颜色以及是否要使用 SANS SERIF 或 SANS 字体。我有背景颜色工作 -
var inputColor = prompt( "Enter a color name for the " +
"background of this page", "" );
document.body.setAttribute( "style", "background-color: " + inputColor );
我不知道如何使用相同的想法并让他们在不擦除新背景颜色的情况下选择字体。
非常感谢您的建议。
【问题讨论】:
-
我会将背景颜色和输入颜色存储到变量中,然后使用 setAttribute 同时设置它们。
标签: javascript css html fonts styles