如何在HTML中的样式标签中添加宽度变量?

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

我有如下标签,

        var width = 300;
        var text = '<hr style="width:+'width'+px;background-color: red!important;color:red !important" >';

我想将width变量应用于style,任何人都可以修改我的代码。谢谢。

javascript html css xhtml
1个回答
0
投票

您好,您有语法错误

 var width = 300;
    var text = '<hr style="width:'+width+'px;background-color: red!important;color:red !important" >';
© www.soinside.com 2019 - 2024. All rights reserved.