gpt4 book ai didi

asp.net-mvc-3 - 将一个类添加到 th

转载 作者:行者123 更新时间:2023-12-04 21:47:21 25 4
gpt4 key购买 nike

在 webgrid 中向 td 添加一个类很容易,例如:

new WebGridColumn {
ColumnName= "Owl.Species",
Header= "Scientific Name",
Style= "sci-name"
}

style 标签将类“sci-name”添加到 td .如何将类添加到 th对于不使用 jQuery 的该列,这不是理想的解决方案。

最佳答案

我认为没有内置的方法可以做到这一点。您甚至不能扩展 WebGrid 类,因为它们的方法没有被标记为虚拟的。我能想到的最好方法是使用一些 CSS,nth-child定位到 th元素按其索引。

<style type='text/css'>
table thead tr th:nth-child(2) {
background: yellow;
}
</style>

仍然不理想,但我认为比使用 JQuery 更好。

关于asp.net-mvc-3 - 将一个类添加到 th,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12249112/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com