我正在使用MVC3 C#4.0构建应用程序
在我看来,我有一张桌子。每行都有一个班级myrowclass
只需执行$(".myrowclass")
,我就可以在jquery中获取表的行
它返回htmltablerowelement
现在我想更改第1行的背景,但我无法这样做
HTML表有很多。 每个都有很多 每个都有一个标签。
我点击一行,并在每个内部点击事件,我想触发一个事件,将改变this.parentElement.parentElement的背景颜色
this.parentElement.parentElement.css(“background-color”,“green”); < - 不工作
但我一直得到HtmlTableRowElement没有.css属性
的错误答案 0 :(得分:0)
详细了解jQuery的.css()
。
$(".myrowclass").css("background-color","green");
$(".myrowclass").addClass("greencssclass");
答案 1 :(得分:0)
要更改CSS样式,请使用:
$(".myrowclass").css("background-color", "green");
要将CSS类添加到元素中,请使用:
$(".myrowclass").addClass("greencssclass");