CSS selector based on element text?(基于元素文本的 CSS 选择器?)
问题描述
有没有办法根据元素文本在css中选择一个元素?
Is there a way to select an element in css based on element text?
即:
li[text=*foo]
<li>foo</li>
<li>bar</li>
这可能行不通.
也只需要支持Chrome即可.
Also only need to support Chrome.
推荐答案
不直接用CSS,你可以根据内部内容通过JavaScript来设置CSS属性,但最终还是需要在CSS的定义中操作.
Not with CSS directly, you could set CSS properties via JavaScript based on the internal contents but in the end you would still need to be operating in the definitions of CSS.
这篇关于基于元素文本的 CSS 选择器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:基于元素文本的 CSS 选择器?
基础教程推荐
- 如何添加到目前为止的天数? 2022-01-01
- 即使用户允许,Gmail 也会隐藏外部电子邮件图片 2022-01-01
- npm start 错误与 create-react-app 2022-01-01
- Bootstrap 模态出现在背景下 2022-01-01
- Fabric JS绘制具有活动形状的多边形 2022-01-01
- 在 contenteditable 中精确拖放 2022-01-01
- Bokeh Div文本对齐 2022-01-01
- fetch 是否支持原生多文件上传? 2022-01-01
- 原生拖动事件后如何获取 mouseup 事件? 2022-01-01
- 检查 HTML5 拖放文件类型 2022-01-01
