基于元素文本的 CSS 选择器? [英] CSS selector based on element text?

查看:13
本文介绍了基于元素文本的 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 选择器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆