在 Chrome 中,style.fontFamily 不适用于条形码字体,但 className 可以

问题描述 投票:0回答:0

考虑以下 html:

<style>
.barcode { font-family: 'BC C39 3 to 1 Medium'; }
</style>
<div><span id='spn'>1234567</span></div>

以下将字体设置为条形码:

<script>
document.getElementById('spn').className = 'barcode';
</script>

但以下不会:

<script>
document.getElementById('spn').style.fontFamily = 'BC C39 3 to 1 Medium';
</script>

为什么?

我需要使用 style.fontFamily 标签,而不是 className,但由于某些原因这似乎是不可能的。

css styles classname
© www.soinside.com 2019 - 2024. All rights reserved.