我有一个 html 字符串,我想使用 jquery 将其作为一行附加到表中,我还想将这个新添加的行的背景颜色更改为红色。这就是我目前只添加没有背景颜色的行所得到的:
$(outputString).appendTo('#billTable tbody').hide().fadeIn(2000);
但是当我尝试使用下面的代码时,我收到一条错误消息“未捕获的语法错误,意外的字符串”:
$(outputString).appendTo('#billTable tbody').css({"background-
color":"red"}).hide().fadeIn(2000);
关于如何添加背景颜色的任何线索?
最佳答案
嗯,这很奇怪 - 您的代码应该可以正常工作。您可以尝试改用它:
$(outputString).appendTo('#billTable tbody').css('background-color', 'red').hide().fadeIn(2000);
我已经替换了
.css({"background-color":"red"})
与
.css('background-color', 'red')
关于javascript - 向表中添加行并更改其背景颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15260645/