使用Javascript动态更改输入文本中的CSS
我正在使用JS、HTML和CSS在线“创建”一个好看的产品比较表。现在,使用此工具生成的示例表如下所示:使用Javascript动态更改输入文本中的CSS,javascript,html,css,dom,Javascript,Html,Css,Dom,我正在使用JS、HTML和CSS在线“创建”一个好看的产品比较表。现在,使用此工具生成的示例表如下所示: <style> tr.numer1 { background-color: #FFFFFF; } tr.numer2 { background-color: #FFFBD0; } td.custTD { border-bottom: 1px solid #CCCCCC; } span.propertyCust { font-weight: bold; co
<style>
tr.numer1
{
background-color: #FFFFFF;
}
tr.numer2
{
background-color: #FFFBD0;
}
td.custTD
{
border-bottom: 1px solid #CCCCCC;
}
span.propertyCust
{
font-weight: bold;
color: #444444;
}
span.productCust
{
font-weight: bold;
color: #444444;
}
body
{
font: 18px Georgia, Serif;
}
</style>
这个表格的样式来自我的HTML的一个样式部分,它看起来像这样:
<style>
tr.numer1
{
background-color: #FFFFFF;
}
tr.numer2
{
background-color: #FFFBD0;
}
td.custTD
{
border-bottom: 1px solid #CCCCCC;
}
span.propertyCust
{
font-weight: bold;
color: #444444;
}
span.productCust
{
font-weight: bold;
color: #444444;
}
body
{
font: 18px Georgia, Serif;
}
</style>
那么:有可能吗?如何实现?如何将整个站点的CSS样式更新为文本区域中输入的样式?您的代码示例几乎正确。在html中放入如下内容:
<style type="text/css" id="table-style"></style>
<textarea id="table-style-textarea"></textarea>
document.getElementById('table-style').innerHTML = document.getElementById('table-style-textarea').value;