html - css 或 xpath 选择器 : elements which have any attribute with specific value

标签 html css dom xpath css-selectors

我想匹配 HTML Dom 树中具有任何属性值为“foo”的所有元素。它应该是 CSS 或 XPath 选择器。

我天真的做法是这样的 css 选择器:

*[*='foo']

正确的语法是怎样的?

最佳答案

CSS 没有定义以通配符作为名称的属性选择器。

然而,XPath 可以。以下表达式应该有效:

//*[@*="foo"]

关于html - css 或 xpath 选择器 : elements which have any attribute with specific value,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5634278/

相关文章:

css - 更改动画或过渡的 SVG Logo 的大小

html - inline-block 从顶部开始显示内容

jQuery 检测上述未知级别的父级?

javascript - 当一个文本 div 更改时,使其他文本 div 更改大小

javascript - css 弹出屏幕动画不起作用

html - child 应该强制 parent 增加它的宽度

javascript - 单击单选按钮时的 JQuery Slidedown() SlideUp()

html - Bootstrap Image Gallery - 自定义 CSS 预加载器

html - DOM 更改时 CSS 适合内容

javascript - 在特定的 div 中向下滚动,而不是在 vanilla JS 中的窗口本身