
A: div class="R clearfix " data-field="xxxx"
B: div class="R clearfix v9d1365e44 "
C: div class="R clearfix " data-field="xxxx"
提取 B, "v9d1365e44"是一串随机字符, 由字母和数字构成.
首先 B 出现在随机位置没办法用第几子元素定位, 以整个 class 字串来定位的话只要随机字串一变就失效.
用:not[class$="clearfix"]也不行, 因为在有的页面 A 和 C 也不是以 clearfix 结尾的(cbright 还是啥的).
我还能想到的就是 regex 去匹配那串随机字符, 但是怎么写进 css 选择器里我就不知道了, 怎么查都没查到, 更不用说 regex 我都是睡一觉就全忘得一干二净......
1 Carseason 2017-10-18 13:02:43 +08:00 via iPhone 用^匹配开始,或者正则 |
2 Troevil 2017-10-18 13:09:04 +08:00 难道不是 :not([data-field]) |
3 cowpea 2017-10-18 13:11:46 +08:00 是你自己页面的话直接给 B 加上别的 css 或者 id 不就可以了。 你控制不了的页面可以先获取到所有 css 再去判断长度 https://gist.github.com/onionc/2990e5cb3dd874037199d7b982c19d45 |
4 lianyue 2017-10-18 13:13:43 +08:00 [class^="R clearfix "] 这样 |
5 cowpea 2017-10-18 13:14:47 +08:00 上面打错,加上 class 不是 css |
6 Chingim 2017-10-18 13:24:20 +08:00 via Android .R.clearfix:not([data-field]) { color:red; } |