gpt4 book ai didi

javascript - 更改 JavaScript 数字变量的字体大小

转载 作者:太空宇宙 更新时间:2023-11-03 21:24:04 28 4
gpt4 key购买 nike

我想更改分配给变量然后打印出来的数字的字体大小。

var secondsPerMinute = 60;
var minsPerHour = 60;

var hoursPerDay = 24;
var daysPerWeek = 7;
var weeksPerYear = 52;
var secondsPerDay = secondsPerMinute*minsPerHour*hoursPerDay;
document.write(secondsPerDay);
var alpha = "blah";
document.write(alpha.fontsize(10));

这里我想更改输出的字体大小 secondsPerDay .. 由于某种原因 .fontsize() 对其不起作用。 我是 javascript 的新手,如果这看起来是个愚蠢的问题,我深表歉意。

最佳答案

根据MDN page on String#fontsize :

Deprecated
This feature has been removed from the Web standards. Though some browsers may still support it, it is in the process of being dropped. Do not use it in old or new projects. Pages or Web apps using it may break at any time.

也不应该使用 document.write, for many reasons .

将输出写入页面上定义的 HTML 元素,使用 CSS 设置样式。例如:

<span id="secondsPerDay" style="font-size: 10px; "></span>
document.getElementById('secondsPerDay').textContent = secondsPerDay;

关于javascript - 更改 JavaScript 数字变量的字体大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34705854/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com