Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to select css id's with numbers in them?

Tags:

css

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" />

The following CSS selector doesn't seem to work:

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

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 am I doing wrong?

like image 711
Nona Avatar asked Jul 22 '15 22:07

Nona


2 Answers

What about using the following selector:

input[id^='something_stuff_'][id$='_work']

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

like image 52
Mindastic Avatar answered Nov 15 '22 23:11

Mindastic


CSS does not support regexes in selectors. Use classes or starts-from and ends-with attribute selectors.

like image 43
c-smile Avatar answered Nov 15 '22 23:11

c-smile