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

查看:118
本文介绍了基于元素文本的CSS选择器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

CSS 3 content selector?


元素在css中基于元素文本?



ie:

  li [text = * foo] 

< li> foo< / li>
< li> bar< / li>

这可能无效..



编辑:也只需要支持Chrome。

解决方案

不直接使用CSS,你可以基于内部内容通过JavaScript设置CSS属性,但最终你仍然需要在CSS的定义中操作。


Possible Duplicate:
CSS 3 content selector?

Is there a way to select an element in css based on element text?

ie:

li[text=*foo]

<li>foo</li>
<li>bar</li>

That probably doesn't work..

I expect the answer is no, but thanks in advance.

Edit: Also only need to support Chrome.

解决方案

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天全站免登陆