gpt4 book ai didi

jquery - 基于表格边框值的 CSS 选择器

转载 作者:行者123 更新时间:2023-11-28 09:01:13 25 4
gpt4 key购买 nike

我想访问 table通过 CSS 选择器在页面中。

表的结构如下:

<table border="1" width="560" cellspacing="0">
<tr>
<td height="28" colspan="3" bgcolor="#FFFFF...>
</tr>
</table>

基本上我需要一行中的 jquery 或 css 选择器来访问 tableborder=1

没有与 table 关联的类或 ID并且第 n 次访问的父子映射也是不可能的

基本上是 table 的选择器其中 table border=1 ( border = 1 不在 style="" 内),它只是 HTML 标记

<table border=1"> ....</table>

最佳答案

您可以使用 attribute selectors

[attr=value]

Represents an element with an attribute name of attr and whose value is exactly "value".

table {
width: 100%;
height: 50px
}
table[border="1"] {
background: red
}
<table border="1">
<tr>
<td></td>
</tr>
</table>
<hr />
<table>
<tr>
<td></td>
</tr>
</table>


注意:但是我建议不要使用 border HTML 标记,因为它已被弃用。要使用 border 设置 table 的样式,您可以使用 CSS 中的 border 属性。

关于jquery - 基于表格边框值的 CSS 选择器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37943583/

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