如何选择带有数字的CSS ID? [英] How to select css id's with numbers in them?

查看:259
本文介绍了如何选择带有数字的CSS ID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我想使用css选择器中的正则表达式来定位类似下面的多个html元素:

So I want to target multiple html element(s) like the below using a regular expression in a css selector:

<input id="something_stuff_013_work" />
<input id="something_stuff_016_work" />

以下CSS选择器似乎无效:

The following CSS selector doesn't seem to work:

input[id*='[0-9]*_work']

我需要对正则表达式中的数字做一些事情,因为输入可以动态添加,并且将为其分配带数字的id。

I need to do something with digits in the regular expression because the inputs can be dynamically added and will be assigned ids with digits in them.

我在做什么错了?

推荐答案

使用以下选择器怎么样?

What about using the following selector:

input [id ^ ='something_stuff _'] [id $ ='_ work']

它将获得ID以 something_stuff_开头,以 _work结尾的输入。

It will get inputs with id starting with "something_stuff_" and finishing with "_work".

这篇关于如何选择带有数字的CSS ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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