CSS选择器(id包含部分文本) [英] CSS selector (id contains part of text)

查看:707
本文介绍了CSS选择器(id包含部分文本)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题。
我有这样的元素:



< a> 元素id = someGenerated一些:相同:0:name



< a> 元素id = someGenerated一些:相同:0: / p>

< a> id = someGenerated的元素部分:相同:1:name



< a> id = someGenerated的元素一些:相同:1:surname



我需要CSS选择器来获取名称。问题是,我不知道如何得到它。
我尝试了 a [id * ='Some:Same'] - 它返回所有< a> 元素。后我可以得到元素的id结束与名称。但我不喜欢这个想法。

解决方案

尝试:

  a [id * ='Some:Same'] [id $ ='name'] 

这将让你所有 a 元素的id包含


一些:相同


并且ID结尾为


名称



I have a question. I have elements something like this:

<a> element with id = someGenerated Some:Same:0:name

<a> element with id = someGenerated Some:Same:0:surname

<a> element with id = someGenerated Some:Same:1:name

<a> element with id = someGenerated Some:Same:1:surname

I need CSS selector to get names. The problem is that I don't know how to get it. I tried a[id*='Some:Same'] - it returned all <a> elements. After I can get elements which id ends with name. But I don't like this idea. I think that it can be done with some other selector.

解决方案

Try this:

a[id*='Some:Same'][id$='name']

This will get you all a elements with id containing

Some:Same

and have the id ending in

name

这篇关于CSS选择器(id包含部分文本)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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