Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Making partial matches with jQuery?

I want to find all input boxes with id containing _date

My code is like this:

<input type="text" name="creation_date" id="id_creation_date" />

Can I use regex for that? Do I need to install something extra for regex to work with jQuery?

like image 599
Mirage Avatar asked Jun 27 '11 05:06

Mirage


2 Answers

I'm thinking of one of these...

$('input[id*="_date"]').css('background-color', 'red');

like image 193
jerluc Avatar answered Nov 16 '22 16:11

jerluc


If you just want to check ending with "_date" rather than containing "_date" you can use

$('input[id$="_date"]')
like image 21
Bharat Patil Avatar answered Nov 16 '22 16:11

Bharat Patil